

def update(self, A):
    '\n        This routine applies the convergence acceleration to the list of individual terms.\n\n        A    = sum(a_k, k = 0..infinity)\n\n        v, e = ...update([a_0, a_1,..., a_k])\n\n        output:\n          v      current estimate of the series A\n          e      an error estimate which is simply the difference between the current\n                 estimate and the last estimate.\n        '
    n = len(A)
    d = ((3 + self.ctx.sqrt(8)) ** n)
    d = ((d + (1 / d)) / 2)
    b = (- self.ctx.one)
    c = (- d)
    s = 0
    for k in xrange(n):
        c = (b - c)
        if ((k % 2) == 0):
            s = (s + (c * A[k]))
        else:
            s = (s - (c * A[k]))
        b = ((((2 * (k + n)) * (k - n)) * b) / (((2 * c) + 1) * (k + self.ctx.one)))
    value = (s / d)
    err = abs((value - self.last))
    self.last = value
    return (value, err)

dataset/ETHPy150Open fredrik-johansson/mpmath/mpmath/calculus/extrapolation.py cohen_alt_class.update/VarMisuse@175/323 `k`->`c`