Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

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 x$x$ from a table of function values yi${y}_{i}$ evaluated at equidistant or non-equidistant points xi${x}_{i}$, for i = 1,2,,n + 1$\mathit{i}=1,2,\dots ,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 x$x$ from a table of values xi${x}_{i}$ and yi${y}_{i}$, for i = 1,2,,n + 1$i=1,2,\dots ,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)${\mathbf{a}}\left(\mathit{i}\right)$ must contain the x$x$-component of the i$\mathit{i}$th data point, xi${x}_{\mathit{i}}$, for i = 1,2,,n + 1$\mathit{i}=1,2,\dots ,n+1$.
2:     b(n1) – double array
b(i)${\mathbf{b}}\left(\mathit{i}\right)$ must contain the y$y$-component (function value) of the i$\mathit{i}$th data point, yi${y}_{\mathit{i}}$, for i = 1,2,,n + 1$\mathit{i}=1,2,\dots ,n+1$.
3:     n – int64int32nag_int scalar
The number of intervals which are to be used in interpolating the value at x$x$; that is, there are n + 1$n+1$ data points (xi,yi)$\left({x}_{i},{y}_{i}\right)$.
Constraint: n > 0${\mathbf{n}}>0$.
4:     x – double scalar
The point x$x$ at which the interpolation is required.

None.

n1 n2

### Output Parameters

1:     a(n1) – double array
n1 = n + 1$\mathit{n1}={\mathbf{n}}+1$.
a(i)${\mathbf{a}}\left(\mathit{i}\right)$ contains the value xix${x}_{\mathit{i}}-x$, for i = 1,2,,n + 1$\mathit{i}=1,2,\dots ,n+1$.
2:     b(n1) – double array
n1 = n + 1$\mathit{n1}={\mathbf{n}}+1$.
The contents of b are unspecified.
3:     c(n2) – double array
n2 = n × (n + 1) / 2$\mathit{n2}={\mathbf{n}}×\left({\mathbf{n}}+1\right)/2$.
• c(1),,c(n)${\mathbf{c}}\left(1\right),\dots ,{\mathbf{c}}\left(n\right)$ contain the first set of linear interpolations,
• c(n + 1),,c(2 × n1)${\mathbf{c}}\left(n+1\right),\dots ,{\mathbf{c}}\left(2×n-1\right)$ contain the second set of linear interpolations,
• c(2n),,c(3 × n3)${\mathbf{c}}\left(2n\right),\dots ,{\mathbf{c}}\left(3×n-3\right)$ contain the third set of linear interpolations,
• $⋮$
• c(n × (n + 1) / 2)${\mathbf{c}}\left(n×\left(n+1\right)/2\right)$ contains the interpolated function value at the point x$x$.

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

The computation time for interpolation at any point x$x$ is proportional to n × (n + 1) / 2$n×\left(n+1\right)/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

```