hide long namesshow long names
hide short namesshow short names
Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

NAG Toolbox: nag_interp_1d_aitken (e01aa)

Purpose

nag_interp_1d_aitken (e01aa) interpolates a function of one variable at a given point xx from a table of function values yiyi evaluated at equidistant or non-equidistant points xixi, for i = 1,2,,n + 1i=1,2,,n+1, using Aitken's technique of successive linear interpolations.

Syntax

[a, b, c] = e01aa(a, b, n, x)
[a, b, c] = nag_interp_1d_aitken(a, b, n, x)
Note: the interface to this routine has changed since earlier releases of the toolbox:
Mark 23: n1 no longer an optional input parameter, n2 no longer an input parameter
.

Description

nag_interp_1d_aitken (e01aa) interpolates a function of one variable at a given point xx from a table of values xixi and yiyi, for i = 1,2,,n + 1i=1,2,,n+1 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.

References

Fröberg C E (1970) Introduction to Numerical Analysis Addison–Wesley

Parameters

Compulsory Input Parameters

1:     a(n1) – double array
a(i)ai must contain the xx-component of the iith data point, xixi, for i = 1,2,,n + 1i=1,2,,n+1.
2:     b(n1) – double array
b(i)bi must contain the yy-component (function value) of the iith data point, yiyi, for i = 1,2,,n + 1i=1,2,,n+1.
3:     n – int64int32nag_int scalar
The number of intervals which are to be used in interpolating the value at xx; that is, there are n + 1n+1 data points (xi,yi)(xi,yi).
Constraint: n > 0n>0.
4:     x – double scalar
The point xx at which the interpolation is required.

Optional Input Parameters

None.

Input Parameters Omitted from the MATLAB Interface

n1 n2

Output Parameters

1:     a(n1) – double array
n1 = n + 1n1=n+1.
a(i)ai contains the value xixxi-x, for i = 1,2,,n + 1i=1,2,,n+1.
2:     b(n1) – double array
n1 = n + 1n1=n+1.
The contents of b are unspecified.
3:     c(n2) – double array
n2 = n × (n + 1) / 2n2=n×(n+1)/2.
  • c(1),,c(n)c1,,cn contain the first set of linear interpolations,
  • c(n + 1),,c(2 × n1)cn+1,,c2×n-1 contain the second set of linear interpolations,
  • c(2n),,c(3 × n3)c2n,,c3×n-3 contain the third set of linear interpolations,
  • c(n × (n + 1) / 2)cn×(n+1)/2 contains the interpolated function value at the point xx.

Error Indicators and Warnings

Accuracy

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 iith set, for i = 1,2,,ni=1,2,,n, is the value at xx of the polynomial interpolating the first (i + 1)(i+1) data points. It is given in position (i1)(2ni + 2) / 2(i-1)(2n-i+2)/2 of the array c. Ideally, providing nn is large enough, this set of nn 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 nn 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 ii data points give good coverage of the neighbourhood of xx, for all ii. To this end, the following ordering is recommended as widely suitable: first the point nearest to xx, then the nearest point on the opposite side of xx, followed by the remaining points in increasing order of their distance from xx, that is of |xrx||xr-x|. 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.

Further Comments

The computation time for interpolation at any point xx is proportional to n × (n + 1) / 2n×(n+1)/2.

Example

function nag_interp_1d_aitken_example
a = [-1;
     -0.5;
     0;
     0.5;
     1;
     1.5];
b = [0;
     -0.53;
     -1;
     -0.46;
     2;
     11.09];
n = int64(5);
x = 0.28;
[aOut, bOut, c] = nag_interp_1d_aitken(a, b, n, x)
 

aOut =

   -1.2800
   -0.7800
   -0.2800
    0.2200
    0.7200
    1.2200


bOut =

         0
   -1.3568
   -1.2370
   -0.8829
   -0.8813
   -0.8359


c =

   -1.3568
   -1.2800
   -0.3925
    1.2800
    5.6781
   -1.2370
   -0.6047
    0.0143
    1.3868
   -0.8829
   -0.8866
   -0.7472
   -0.8813
   -0.9127
   -0.8359


function e01aa_example
a = [-1;
     -0.5;
     0;
     0.5;
     1;
     1.5];
b = [0;
     -0.53;
     -1;
     -0.46;
     2;
     11.09];
n = int64(5);
x = 0.28;
[aOut, bOut, c] = e01aa(a, b, n, x)
 

aOut =

   -1.2800
   -0.7800
   -0.2800
    0.2200
    0.7200
    1.2200


bOut =

         0
   -1.3568
   -1.2370
   -0.8829
   -0.8813
   -0.8359


c =

   -1.3568
   -1.2800
   -0.3925
    1.2800
    5.6781
   -1.2370
   -0.6047
    0.0143
    1.3868
   -0.8829
   -0.8866
   -0.7472
   -0.8813
   -0.9127
   -0.8359



PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2013