E01 Chapter Contents
E01 Chapter Introduction
NAG Library Manual

# NAG Library Routine DocumentE01AAF

Note:  before using this routine, please read the Users' Note for your implementation to check the interpretation of bold italicised terms and other implementation-dependent details.

## 1  Purpose

E01AAF interpolates a function of one variable at a given point $x$ from a table of function values ${y}_{i}$ evaluated at equidistant or non-equidistant points ${x}_{i}$, for $\mathit{i}=1,2,\dots ,n+1$, using Aitken's technique of successive linear interpolations.

## 2  Specification

 SUBROUTINE E01AAF ( A, B, C, N1, N2, N, X)
 INTEGER N1, N2, N REAL (KIND=nag_wp) A(N1), B(N1), C(N2), X

## 3  Description

E01AAF interpolates a function of one variable at a given point $x$ from a table of values ${x}_{i}$ and ${y}_{i}$, for $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.

## 4  References

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

## 5  Parameters

1:     A(N1) – REAL (KIND=nag_wp) arrayInput/Output
On entry: ${\mathbf{A}}\left(\mathit{i}\right)$ must contain the $x$-component of the $\mathit{i}$th data point, ${x}_{\mathit{i}}$, for $\mathit{i}=1,2,\dots ,n+1$.
On exit: ${\mathbf{A}}\left(\mathit{i}\right)$ contains the value ${x}_{\mathit{i}}-x$, for $\mathit{i}=1,2,\dots ,n+1$.
2:     B(N1) – REAL (KIND=nag_wp) arrayInput/Output
On entry: ${\mathbf{B}}\left(\mathit{i}\right)$ must contain the $y$-component (function value) of the $\mathit{i}$th data point, ${y}_{\mathit{i}}$, for $\mathit{i}=1,2,\dots ,n+1$.
On exit: the contents of B are unspecified.
3:     C(N2) – REAL (KIND=nag_wp) arrayOutput
On exit:
• ${\mathbf{C}}\left(1\right),\dots ,{\mathbf{C}}\left(n\right)$ contain the first set of linear interpolations,
• ${\mathbf{C}}\left(n+1\right),\dots ,{\mathbf{C}}\left(2×n-1\right)$ contain the second set of linear interpolations,
• ${\mathbf{C}}\left(2n\right),\dots ,{\mathbf{C}}\left(3×n-3\right)$ contain the third set of linear interpolations,
• $⋮$
• ${\mathbf{C}}\left(n×\left(n+1\right)/2\right)$ contains the interpolated function value at the point $x$.
4:     N1 – INTEGERInput
On entry: the value $n+1$ where $n$ is the number of intervals; that is, N1 is the number of data points.
5:     N2 – INTEGERInput
On entry: the value $n×\left(n+1\right)/2$ where $n$ is the number of intervals.
6:     N – INTEGERInput
On entry: the number of intervals which are to be used in interpolating the value at $x$; that is, there are $n+1$ data points $\left({x}_{i},{y}_{i}\right)$.
Constraint: ${\mathbf{N}}>0$.
7:     X – REAL (KIND=nag_wp)Input
On entry: the point $x$ at which the interpolation is required.

None.

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

## 9  Example

This example interpolates at $x=0.28$ the function value of a curve defined by the points
 $xi -1.00 -0.50 0.00 0.50 1.00 1.50 yi 0.00 -0.53 -1.00 -0.46 2.00 11.09 .$

### 9.1  Program Text

Program Text (e01aafe.f90)

### 9.2  Program Data

Program Data (e01aafe.d)

### 9.3  Program Results

Program Results (e01aafe.r)