E01 Chapter Contents
E01 Chapter Introduction
NAG Library Manual

# NAG Library Routine DocumentE01ABF

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

E01ABF interpolates a function of one variable at a given point $x$ from a table of function values evaluated at equidistant points, using Everett's formula.

## 2  Specification

 SUBROUTINE E01ABF ( N, P, A, G, N1, N2, IFAIL)
 INTEGER N, N1, N2, IFAIL REAL (KIND=nag_wp) P, A(N1), G(N2)

## 3  Description

E01ABF interpolates a function of one variable at a given point
 $x=x0+ph,$
where $-1 and $h$ is the interval of differencing, from a table of values ${x}_{m}={x}_{0}+mh$ and ${y}_{m}$ where $m=-\left(n-1\right),-\left(n-2\right),\dots ,-1,0,1,\dots ,n$. The formula used is that of Fröberg (1970), neglecting the remainder term:
 $yp=∑r=0 n-1 1-p+r 2r+1 δ2ry0+∑r=0 n-1 p+r 2r+1 δ2ry1.$
The values of ${\delta }^{2r}{y}_{0}$ and ${\delta }^{2r}{y}_{1}$ are stored on exit from the routine in addition to the interpolated function value ${y}_{p}$.

## 4  References

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

## 5  Parameters

1:     N – INTEGERInput
On entry: $n$, half the number of points to be used in the interpolation.
Constraint: ${\mathbf{N}}>0$.
2:     P – REAL (KIND=nag_wp)Input
On entry: the point $p$ at which the interpolated function value is required, i.e., $p=\left(x-{x}_{0}\right)/h$ with $-1.0.
Constraint: $-1.0<{\mathbf{P}}<1.0$.
3:     A(N1) – REAL (KIND=nag_wp) arrayInput/Output
On entry: ${\mathbf{A}}\left(\mathit{i}\right)$ must be set to the function value ${y}_{\mathit{i}-n}$, for $\mathit{i}=1,2,\dots ,2n$.
On exit: the contents of A are unspecified.
4:     G(N2) – REAL (KIND=nag_wp) arrayOutput
On exit: the array contains
 $\phantom{{\delta }^{2r}}{y}_{0}$ in ${\mathbf{G}}\left(1\right)$ $\phantom{{\delta }^{2r}}{y}_{1}$ in ${\mathbf{G}}\left(2\right)$ ${\delta }^{2r}{y}_{0}$ in ${\mathbf{G}}\left(2r+1\right)$ ${\delta }^{2r}{y}_{1}$ in ${\mathbf{G}}\left(2\mathit{r}+2\right)$, for $\mathit{r}=1,2,\dots ,n-1$.
The interpolated function value ${y}_{p}$ is stored in ${\mathbf{G}}\left(2n+1\right)$.
5:     N1 – INTEGERInput
On entry: the value $2n$, that is, N1 is equal to the number of data points.
6:     N2 – INTEGERInput
On entry: the value $2n+1$, that is, N2 is one more than the number of data points.
7:     IFAIL – INTEGERInput/Output
On entry: IFAIL must be set to $0$, $-1\text{​ or ​}1$. If you are unfamiliar with this parameter you should refer to Section 3.3 in the Essential Introduction for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value $-1\text{​ or ​}1$ is recommended. If the output of error messages is undesirable, then the value $1$ is recommended. Otherwise, if you are not familiar with this parameter, the recommended value is $0$. When the value $-\mathbf{1}\text{​ or ​}\mathbf{1}$ is used it is essential to test the value of IFAIL on exit.
On exit: ${\mathbf{IFAIL}}={\mathbf{0}}$ unless the routine detects an error or a warning has been flagged (see Section 6).

## 6  Error Indicators and Warnings

If on entry ${\mathbf{IFAIL}}={\mathbf{0}}$ or $-{\mathbf{1}}$, explanatory error messages are output on the current error message unit (as defined by X04AAF).
Errors or warnings detected by the routine:
${\mathbf{IFAIL}}=1$
 On entry, ${\mathbf{P}}\le -1.0$, or ${\mathbf{P}}\ge 1.0$.

## 7  Accuracy

In general, increasing $n$ improves the accuracy of the result until full attainable accuracy is reached, after which it might deteriorate. If $x$ lies in the central interval of the data (i.e., $0.0\le p<1.0$), as is desirable, an upper bound on the contribution of the highest order differences (which is usually an upper bound on the error of the result) is given approximately in terms of the elements of the array G by $a×\left(\left|{\mathbf{G}}\left(2n-1\right)\right|+\left|{\mathbf{G}}\left(2n\right)\right|\right)$, where $a=0.1$, $0.02$, $0.005$, $0.001$, $0.0002$ for $n=1,2,3,4,5$ respectively, thereafter decreasing roughly by a factor of $4$ each time.

The computation time increases as the order of $n$ increases.

## 9  Example

This example interpolates at the point $x=0.28$ from the function values
 $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 .$
We take $n=3$ and $p=0.56$.

### 9.1  Program Text

Program Text (e01abfe.f90)

### 9.2  Program Data

Program Data (e01abfe.d)

### 9.3  Program Results

Program Results (e01abfe.r)