Note: the interface to this routine has changed since earlier releases of the toolbox:
At Mark 23: |
n1 is no longer an optional input parameter; n2 is no longer an input parameter |
nag_interp_1d_aitken (e01aa) interpolates a function of one variable at a given point
from a table of values
and
, for
using Aitken's method (see
Fröberg (1970)). The intermediate values of linear interpolations are stored to enable an estimate of the accuracy of the results to be made.
None.
None.
An estimate of the accuracy of the result can be made from a comparison of the final result and the previous interpolates, given in the array
c. In particular, the first interpolate in the
th set, for
, is the value at
of the polynomial interpolating the first
data points. It is given in position
of the array
c. Ideally, providing
is large enough, this set of
interpolates should exhibit convergence to the final value, the difference between one interpolate and the next settling down to a roughly constant magnitude (but with varying sign). This magnitude indicates the size of the error (any subsequent increase meaning that the value of
is too high). Better convergence will be obtained if the data points are supplied, not in their natural order, but ordered so that the first
data points give good coverage of the neighbourhood of
, for all
. To this end, the following ordering is recommended as widely suitable: first the point nearest to
, then the nearest point on the opposite side of
, followed by the remaining points in increasing order of their distance from
, that is of
. With this modification the Aitken method will generally perform better than the related method of Neville, which is often given in the literature as superior to that of Aitken.
This example interpolates at
the function value of a curve defined by the points
function e01aa_example
fprintf('e01aa example results\n\n');
a = [-1 -0.50 0 0.50 1 1.50];
b = [ 0 -0.53 -1 -0.46 2 11.09];
n = int64(5);
x = 0.28;
[ax, bx, c] = e01aa(a, b, n, x);
k = 1;
disp('Interpolated values');
for i = n-1:-1:1
fprintf('%12.5f',c(k:k+i));
fprintf('\n');
k = k + i + 1;
end
fprintf('\nInterpolation point = %12.5f\n', x);
fprintf('\nFunction value at interpolation point = %12.5f\n', c(end));