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_everett (e01ab)

## Purpose

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

## Syntax

[a, g, ifail] = e01ab(n, p, a)
[a, g, ifail] = nag_interp_1d_everett(n, p, a)
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_everett (e01ab) interpolates a function of one variable at a given point
 x = x0 + ph, $x=x0+ph,$
where 1 < p < 1$-1 and h$h$ is the interval of differencing, from a table of values xm = x0 + mh${x}_{m}={x}_{0}+mh$ and ym${y}_{m}$ where m = (n1),(n2),,1,0,1,,n$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:
 n − 1 n − 1 yp = ∑ ((1 − p + r)/(2r + 1))δ2ry0 + ∑ ((p + r)/(2r + 1))δ2ry1. r = 0 r = 0
$yp=∑r=0 n-1 (1-p+r 2r+1 ) δ2ry0+∑r=0 n-1 (p+r 2r+1 ) δ2ry1.$
The values of δ2ry0${\delta }^{2r}{y}_{0}$ and δ2ry1${\delta }^{2r}{y}_{1}$ are stored on exit from the function in addition to the interpolated function value yp${y}_{p}$.

## References

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

## Parameters

### Compulsory Input Parameters

1:     n – int64int32nag_int scalar
n$n$, half the number of points to be used in the interpolation.
Constraint: n > 0${\mathbf{n}}>0$.
2:     p – double scalar
The point p$p$ at which the interpolated function value is required, i.e., p = (xx0) / h$p=\left(x-{x}_{0}\right)/h$ with 1.0 < p < 1.0$-1.0.
Constraint: 1.0 < p < 1.0$-1.0<{\mathbf{p}}<1.0$.
3:     a(n1) – double array
a(i)${\mathbf{a}}\left(\mathit{i}\right)$ must be set to the function value yin${y}_{\mathit{i}-n}$, for i = 1,2,,2n$\mathit{i}=1,2,\dots ,2n$.

None.

n1 n2

### Output Parameters

1:     a(n1) – double array
n1 = 2 × n$\mathit{n1}=2×{\mathbf{n}}$.
The contents of a are unspecified.
2:     g(n2) – double array
n2 = 2 × n + 1$\mathit{n2}=2×{\mathbf{n}}+1$.
The array contains
 δ2ry0$\phantom{{\delta }^{2r}}{y}_{0}$ in g(1)${\mathbf{g}}\left(1\right)$ δ2ry1$\phantom{{\delta }^{2r}}{y}_{1}$ in g(2)${\mathbf{g}}\left(2\right)$ δ2ry0${\delta }^{2r}{y}_{0}$ in g(2r + 1)${\mathbf{g}}\left(2r+1\right)$ δ2ry1${\delta }^{2r}{y}_{1}$ in g(2r + 2)${\mathbf{g}}\left(2\mathit{r}+2\right)$, for r = 1,2, … ,n − 1$\mathit{r}=1,2,\dots ,n-1$.
The interpolated function value yp${y}_{p}$ is stored in g(2n + 1)${\mathbf{g}}\left(2n+1\right)$.
3:     ifail – int64int32nag_int scalar
${\mathrm{ifail}}={\mathbf{0}}$ unless the function detects an error (see [Error Indicators and Warnings]).

## Error Indicators and Warnings

Errors or warnings detected by the function:
ifail = 1${\mathbf{ifail}}=1$
 On entry, p ≤ − 1.0${\mathbf{p}}\le -1.0$, or p ≥ 1.0${\mathbf{p}}\ge 1.0$.

## Accuracy

In general, increasing n$n$ improves the accuracy of the result until full attainable accuracy is reached, after which it might deteriorate. If x$x$ lies in the central interval of the data (i.e., 0.0p < 1.0$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 × (|g(2n1)| + |g(2n)|)$a×\left(|{\mathbf{g}}\left(2n-1\right)|+|{\mathbf{g}}\left(2n\right)|\right)$, where a = 0.1$a=0.1$, 0.02$0.02$, 0.005$0.005$, 0.001$0.001$, 0.0002$0.0002$ for n = 1,2,3,4,5$n=1,2,3,4,5$ respectively, thereafter decreasing roughly by a factor of 4$4$ each time.

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

## Example

```function nag_interp_1d_everett_example
n = int64(3);
p = 0.56;
a = [0;
-0.53;
-1;
-0.46;
2;
11.09];
[aOut, g, ifail] = nag_interp_1d_everett(n, p, a)
```
```

aOut =

-0.0400
3.8000
-20.4300
15.7200
-9.0900
11.0900

g =

-1.0000
-0.4600
1.0100
1.9200
-0.0400
3.8000
-0.8359

ifail =

0

```
```function e01ab_example
n = int64(3);
p = 0.56;
a = [0;
-0.53;
-1;
-0.46;
2;
11.09];
[aOut, g, ifail] = e01ab(n, p, a)
```
```

aOut =

-0.0400
3.8000
-20.4300
15.7200
-9.0900
11.0900

g =

-1.0000
-0.4600
1.0100
1.9200
-0.0400
3.8000
-0.8359

ifail =

0

```