5.1.3.3. numdifftools.extrapolation.dea3
- dea3(v_0, v_1, v_2, symmetric=False)[source]
Extrapolates a slowly convergent sequence using Shanks transformations.
- Parameters:
v_0 (array-like) – Three consecutive values of a convergent sequence to extrapolate.
v_1 (array-like) – Three consecutive values of a convergent sequence to extrapolate.
v_2 (array-like) – Three consecutive values of a convergent sequence to extrapolate.
symmetric (bool, optional) – If True, returns a sequence with symmetric error estimates. Defaults to False.
- Returns:
result (array-like) – The extrapolated value(s).
abserr (array-like) – The estimated absolute error(s).
Notes
DEA3 uses nonlinear Shanks transformations based on three values to extrapolate to a better estimate of the sequence’s limit. It is a vectorized translation of the DQELG function from the QUADPACK Fortran library. for LIMEXP=3, see [2] and [3].
Examples
# integrate sin(x) from 0 to pi/2
>>> import numpy as np >>> import numdifftools as nd >>> Ei= np.zeros(3) >>> linfun = lambda i : np.linspace(0, np.pi/2., 2**(i+5)+1) >>> for k in np.arange(3): ... x = linfun(k) ... Ei[k] = np.trapezoid(np.sin(x),x) >>> [En, err] = nd.dea3(Ei[0], Ei[1], Ei[2]) >>> truErr = np.abs(En-1.) >>> bool(np.all(truErr < err)) True >>> np.allclose(En, 1) True >>> bool(np.all(np.abs(Ei-1)<1e-3)) True
See also
References