We'll give an example of the application of generators for convergence acceleration. This presentation closely follows the example given in [9].
Note that a generator may take another generator as an input parameter. For instance, suppose that we have defined a generator that generates the elements of a converging sequence. It is then possible to improve the convergence by an acceleration technique due to Euler and Aitken, often called Aitken's Δ2-method, see [33]. It transforms a sequence into another by defining
Both sequences have the same limit, but the sequence converges significantly faster. One possible implementation is as follows:
def Euler_accelerate(sequence): """ Accelerate the iterator in the variable `sequence`. """ s0 = sequence.__next__() # Si s1 = sequence.__next__() # Si+1 s2 = sequence.__next__() # Si+2 while True: ...