Suppose that we wish to approximate, and we have a method that depends on a small parameter in such a way that Let us define a new function where and are two distinct step sizes. Then is called the Richardson extrapolation of A, and has a higher-order error estimate compared to. Very often, it is much easier to obtain a given precision by using R rather than A with a much smaller h' . Where A can cause problems due to limited precision and/or due to the increasing number of calculations needed.
General formula
Let ' be an approximation of ' that depends on a positive step sizeh with an error formula of the form where the ai are unknown constants and the ki are known constants such that hki > hki+1. k0 is the leading order step size behavior of Truncation error as The exact value sought can be given by which can be simplified with Big O notation to be Using the step sizes h and for some constant t, the two formulas for A are: Multiplying the second equation by tk0 and subtracting the first equation gives which can be solved for to give Therefore, using the truncation error has been reduced to . This is in contrast to where the truncation error is for the same step size By this process, we have achieved a better approximation of A by subtracting the largest term in the error which was O. This process can be repeated to remove more error terms to get even better approximations. A general recurrence relation beginning with can be defined for the approximations by where satisfies The Richardson extrapolation can be considered as a linear sequence transformation. Additionally, the general formula can be used to estimate k0 when neither its value nor A* is known a priori. Such a technique can be useful for quantifying an unknown rate of convergence. Given approximations of A from three distinct step sizes h, h / t, and h / s, the exact relationship yields an approximate relationship which can be solved numerically to estimate k0 for some arbitrary choices of h, s and t.
Example pseudocode code for Richardson extrapolation
The following pseudocode in MATLAB style demonstrates Richardson extrapolation to help solve the ODE, with the Trapezoidal method. In this example we halve the step size each iteration and so in the discussion above we'd have that. The error of the Trapezoidal method can be expressed in terms of odd powers so that the error over multiple steps can be expressed in even powers; this leads us to raise to the second power and to take powers of in the pseudocode. We want to find the value of, which has the exact solution of since the exact solution of the ODE is. This pseudocode assumes that a function called Trapezoidal exists which attempts to computes y by performing the trapezoidal method on the function f, with starting point y0 and tStart and step size h. Note that starting with too small an initial step size can potentially introduce error into the final solution. Although there are methods designed to help pick the best initial step size, one option is to start with a large step size and then to allow the Richardson extrapolation to reduce the step size each iteration until the error reaches the desired tolerance. tStart = 0 % Starting time tEnd = 5 % Ending time f = -y^2 % The derivative of y, so y' = f = -y^2 % The solution to this ODE is y = 1/ y0 = 1 % The initial position = y tolerance = 10^-11 % 10 digit accuracy is desired maxRows = 20 % Don't allow the iteration to continue indefinitely initialH = tStart - tEnd % Pick an initial step size haveWeFoundSolution = false % Were we able to find the solution to within the desired tolerance? not yet. h = initialH % Create a 2D matrix of size maxRows by maxRows to hold the Richardson extrapolates % Note that this will be a lower triangular matrix and that at most two rows are actually % needed at any time in the computation. A = zeroMatrix %Compute the top left element ofthe matrix A = Trapezoidal % Each row of the matrix requires one call to Trapezoidal % This loops starts by filling the second row of the matrix, since the first row was computed above for i = 1 : maxRows - 1 % Starting at i = 1, iterate at most maxRows - 1 times h = h/2 % Half the previous value of h since this is the start of a new row
% Call the Trapezoidal function with this new smaller step size A = Trapezoidal
for j = 1 : i % Go across the row until the diagonal is reached % Use the value just computed and the element from the % row above it to compute the next Richardson extrapolate
A =.*A - A)/; end
% After leaving the above inner loop, the diagonal element of row i + 1 has been computed % This diagonal element is the latest Richardson extrapolate to be computed. % The difference between this extrapolate and the last extrapolate of row i is a good % indication of the error. if - A) < tolerance) % If the result is within tolerance print = ", A) % Display the result of the Richardson extrapolation haveWeFoundSolution = true break % Done, so leave the loop end end if % If we weren't able to find a solution to within the desired tolerance print; print end