def update(self,X):
        """
        This routine applies the convergence acceleration to the list of individual terms.

        A = sum(a_k, k = 0..infinity)

        v, e = ...update([a_0, a_1,..., a_k])

        output:
          v      current estimate of the series A
          e      an error estimate which is simply the difference between the current
                 estimate and the last estimate.
        """

        if self.variant!="v":
            if self.n==0:
                self.s=X[0]
                self.run(self.s,X[0])
            while self.n<len(X):
                self.s+=X[self.n]
                self.run(self.s,X[self.n])
        else:
            if len(X)==1:
                self.last=0
                return X[0],abs(X[0])

            if self.n==0:
                self.s=X[0]
                self.run(self.s,X[0],X[1])

            while self.n<len(X)-1:
                self.s+=X[self.n]
                self.run(self.s,X[self.n],X[self.n+1])

        value=self.A[0]/self.B[0]
        err=abs(value-self.last)
        self.last=value

        return value,err

    ###########################################################################
dataset/ETHPy150Open fredrik-johansson/mpmath/mpmath/calculus/extrapolation.py/levin_class.update/original