levin(s[, type, k0, degree, ds]) | Return the triangular acceleration table a for n terms of |
This module provides some techniques for sequence acceleration.
Most of the theory and notation follows D. Laurie’s discussion in Appendix A. of [R4]. The general model is that the sequence has the form:
where is the converged result, is some set of known residual dependencies with unknown coefficients and is a residual that will be taken to be negligible [R3].
The acceleration will be summarized in a table of coefficients as follows:
where the arrows show the dependencies: Each term is a function of the terms . The first column is thus the original sequence.
Here we consider linear sequence transformations such that . In particular, we consider each column of to be a linear transformation of the previous column: . In this case, we may provide an explicit construction using n terms that eliminates the first n residuals by demanding:
(1)
This defines the entry in terms of the original elements of the sequence below and to the left by defining equations for the unknowns . Note that for each , the set of coefficients is different because this is not the original sequence (for example, we have truncated and ignored the error terms ).
Naively, one may directly solve these systems of equations for each of entries , but this takes operations. There is a general procedure called the “E-algorithm” that reduces this to which we now present. This is implemented by e_algorithm(). For special forms of the residuals specialized methods exist which are often much faster. Some of these are described later.
Note
For linear models, one should obtain convergence either proceeding down or to the right, but the key feature is that the convergence of the rows to the right should be much faster: this indicates that the underlying model is good. If the rows do not converge much faster than the columns, one should consider a different acceleration technique.
As we discussed above, each successive column of S may be expressed in terms of this as an affine combination of the previous two entries and :
(The affinity is required to preserve the linearity, for example, so that and converge to the same value .)
Start with the original sequence as the first column of . Consider this, along with the new sequence and the sequence of residuals . The transformation can be represented as a matrix:
Equations (1) for are then satisfied if which defines the coefficients:
The E-algorithm is then to apply this transformation to the rest of the columns of to obtain a new set of residuals (the first column having been annihilated). Now treat as the new original sequence and repeat the process. This is implemented by e_algorithm(). In certain special cases, one can directly derive formula for the coefficients . The table can them be directly constructed. This is done in direct_algorithm().
To estimate the error-sensitivity, we consider each entry to be a function of the original sequence entries. Given errors in the input , an estimate of the error in the result is
For linear algorithms, this is easy to compute since where . The squares of the errors will be the diagonals of the matrix .
For some of the faster specialized algorithms, it is a bit cumbersome to compute this exactly, so we directly propagate the errors as either
or
This will overestimate the errors as cancellations that occur at various stages are not taken into account, but in practise, this is not very significant.
The Richardson extrapolation method considers models of the form
(2)
These most typically arise in problems such as differentiation, integration, or discretization where there is a step-size that is decreased at successive stages. The most general model (2) requires the full E-algorithm, but there are several special cases that admit analytic solutions:
Geometric progression of step sizes with constant r:
Arithmetic progression of exponents:
The modified Salzer’s extrapolation is based on a model of the form
This provides another efficient method which can be derived by dividing (1) by :
From this we can construct the solution in terms of the divided difference operators : at which acts as a difference of the sequence as a function of . The idea here is that the sum on the right is a polynomial of order in t_k, and hence will be annihilated by the n th difference operator at .
The previous linear acceleration techniques are fairly robust, and one can generally prove that if the original sequence converges, then the accelerated sequence will also converge to the same limit. However, to obtain convergence, one must put good inputs into the model (1).
Perhaps the most famous of these methods are those due to Levin. These are generalizations of the Salzer expansion where the function is expressed in terms of the residuals of the sequence (as opposed to linear methods where is determined a priori independently of the actual sequence). Semi-linear methods often work well, even if no a priori information about the sequence is know, however, they are also more difficult to characterize. (For example, even if the transformation is exact for two sequences, it may not be exact for them sum as the transformations are not completely linear.)
To understand where the Levin transformation works, note that
The three most common Levin accelerations are:
T:
U:
W:
[R3] | Determining the form of is somewhat of an art. It is not just sufficient to choose an accurate sequence: the residual that remains after summing m terms must really be negligible. For example, consider with partial sums . From the residual, one might be tempted to use which will ultimately be exact. However, after summing only n terms, the residual will still be which is certainly not negligible if the series needs convergence acceleration! Instead, one must find a good set of approximation that fall off sufficiently rapidly which is why these types of sequences work well with Salzar’s modified algorithm. |
[R4] | F. Bornemann, D. Laurie, S. Wagon, and J. Waldvogel, The SIAM 100-Digit Challenge: A Study in High-Accuracy Numerical Computing, SIAM, 2004. |
Return the triangular acceleration table a for n terms of the sequence s[k] using the Levin transformation type.
Parameters : | s : 1-d array of length n
type : ‘t’, ‘u’, or ‘w’
k0 : float
degree : int
ds : None or float or 1-d array of length n
|
---|---|
Returns : | S : array (n x n)
dS : array (n x n)
|