def update_psum(self, S):

        n = len(S)
        d = (3 + self.ctx.sqrt(8)) ** n
        d = (d + 1 / d) / 2
        b = self.ctx.one
        s = 0

        for k in xrange(n):
            b = 2 * (n + k) * (n - k) * b / ((2 * k + 1) * (k + self.ctx.one))
            s += b * S[k]

        value = s / d

        err = abs(value - self.last)
        self.last = value

        return value, err
This routine applies the convergence acceleration to the list of partial sums.
dataset/ETHPy150Open fredrik-johansson/mpmath/mpmath/calculus/extrapolation.py/cohen_alt_class.update_psum