February 2019
Intermediate to advanced
672 pages
16h 50m
English
Let us consider a quick example:
Computing f1000(3), with f(x) = x2 - x + 1, and fn + 1(x) = f(fn(x)).
With complicated functions like f (where it is relatively difficult to find a general form of fn(x)), the only obviously reasonable way to compute f1000(3) or similar values is to iteratively compute f2(3) = f( f(3)), f3(3) = f( f2(3)), ... , f999(3) = f( f998(3)), and, finally, f1000(3) = f( f999(3)).
Since it will take significant time to actually compute f1000(3), even when using a computer, we will only consider f20(3) in our code (my laptop actually started heating up after f25(3)):
# Chapter08/example2.pydef f(x): return x * x - x + 1# sequentialdef f(x): return x * x - x + 1start = timer()