# NAG CL Interfacee01aac (dim1_​aitken)

Settings help

CL Name Style:

## 1Purpose

e01aac 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.

## 2Specification

 #include
 void e01aac (Integer n, double a[], double b[], double c[], double x, NagError *fail)
The function may be called by the names: e01aac, nag_interp_dim1_aitken or nag_1d_aitken_interp.

## 3Description

e01aac 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.

## 4References

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

## 5Arguments

1: $\mathbf{n}$Integer Input
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$.
2: $\mathbf{a}\left[{\mathbf{n}}+1\right]$double Input/Output
On entry: ${\mathbf{a}}\left[\mathit{i}-1\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}-1\right]$ contains the value ${x}_{\mathit{i}}-x$, for $\mathit{i}=1,2,\dots ,n+1$.
3: $\mathbf{b}\left[{\mathbf{n}}+1\right]$double Input/Output
On entry: ${\mathbf{b}}\left[\mathit{i}-1\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.
4: $\mathbf{c}\left[{\mathbf{n}}×\left({\mathbf{n}}+1\right)/2\right]$double Output
On exit:
• ${\mathbf{c}}\left[0\right],\dots ,{\mathbf{c}}\left[n-1\right]$ contain the first set of linear interpolations,
• ${\mathbf{c}}\left[n\right],\dots ,{\mathbf{c}}\left[2×n-2\right]$ contain the second set of linear interpolations,
• ${\mathbf{c}}\left[2n-1\right],\dots ,{\mathbf{c}}\left[3×n-4\right]$ contain the third set of linear interpolations,
• $⋮$
• ${\mathbf{c}}\left[n×\left(n+1\right)/2-1\right]$ contains the interpolated function value at the point $x$.
5: $\mathbf{x}$double Input
On entry: the point $x$ at which the interpolation is required. Note that x may lie outside the interval defined by the minimum and maximum values in a, in which case an extrapolated value will be computed; extrapolated results should be treated with considerable caution since there is no information on the behaviour of the function outside the defined interval.
6: $\mathbf{fail}$NagError * Input/Output
The NAG error argument (see Section 7 in the Introduction to the NAG Library CL Interface).

## 6Error Indicators and Warnings

NE_ALLOC_FAIL
Dynamic memory allocation failed.
See Section 3.1.2 in the Introduction to the NAG Library CL Interface for further information.
On entry, argument $⟨\mathit{\text{value}}⟩$ had an illegal value.
NE_INT
On entry, ${\mathbf{n}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{n}}>0$.
NE_INTERNAL_ERROR
An internal error has occurred in this function. Check the function call and any array sizes. If the call is correct then please contact NAG for assistance.
See Section 7.5 in the Introduction to the NAG Library CL Interface for further information.
NE_NO_LICENCE
Your licence key may have expired or may not have been installed correctly.
See Section 8 in the Introduction to the NAG Library CL Interface for further information.

## 7Accuracy

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 $|{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.

## 8Parallelism and Performance

e01aac is not threaded in any implementation.

The computation time for interpolation at any point $x$ is proportional to $n×\left(n+1\right)/2$.

## 10Example

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 ) .$

### 10.1Program Text

Program Text (e01aace.c)

### 10.2Program Data

Program Data (e01aace.d)

### 10.3Program Results

Program Results (e01aace.r)