NAG FL Interface
e01abf (dim1_​everett)

Settings help

FL Name Style:


FL Specification Language:


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

Fortran Interface
Subroutine e01abf ( n, p, a, g, n1, n2, ifail)
Integer, Intent (In) :: n, n1, n2
Integer, Intent (Inout) :: ifail
Real (Kind=nag_wp), Intent (In) :: p
Real (Kind=nag_wp), Intent (Inout) :: a(2*n)
Real (Kind=nag_wp), Intent (Out) :: g(2*n+1)
C Header Interface
#include <nag.h>
void  e01abf_ (const Integer *n, const double *p, double a[], double g[], const Integer *n1, const Integer *n2, Integer *ifail)
The routine may be called by the names e01abf or nagf_interp_dim1_everett.

3 Description

e01abf interpolates a function of one variable at a given point
x=x0+ph,  
where -1p1 and h is the interval of differencing, from a table of values xm=x0+mh and ym where m=-(n-1),-(n-2),,-1,0,1,,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 δ2ry0 and δ2ry1 are stored on exit from the routine in addition to the interpolated function value yp.

4 References

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

5 Arguments

1: n Integer Input
On entry: n, half the number of points to be used in the interpolation.
Constraint: 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=(x-x0)/h with -1.0<p<1.0.
Constraint: -1.0p1.0.
3: a(2×n) Real (Kind=nag_wp) array Input/Output
On entry: a(i) must be set to the function value yi-n, for i=1,2,,2n.
On exit: the contents of a are unspecified.
4: g(2×n+1) Real (Kind=nag_wp) array Output
On exit: the array contains
δ2ry0 in g(1)
δ2ry1 in g(2)
δ2ry0 in g(2r+1)
δ2ry1 in g(2r+2), for r=1,2,,n-1.
The interpolated function value yp is stored in g(2n+1).
5: n1 Integer Input
6: n2 Integer Input
On entry: these arguments are no longer referenced, but is included for backwards compatability.
7: ifail Integer Input/Output
On entry: ifail must be set to 0, −1 or 1 to set behaviour on detection of an error; these values have no effect when no error is detected.
A value of 0 causes the printing of an error message and program execution will be halted; otherwise program execution continues. A value of −1 means that an error message is printed while a value of 1 means that it is not.
If halting is not appropriate, the value −1 or 1 is recommended. If message printing is undesirable, then the value 1 is recommended. Otherwise, the value 0 is recommended. When the value -1 or 1 is used it is essential to test the value of ifail on exit.
On exit: ifail=0 unless the routine detects an error or a warning has been flagged (see Section 6).

6 Error Indicators and Warnings

If on entry ifail=0 or −1, explanatory error messages are output on the current error message unit (as defined by x04aaf).
Errors or warnings detected by the routine:
ifail=1
On entry, p=value.
Constraint: p1.0.
On entry, p=value.
Constraint: p-1.0.
ifail=2
On entry, n=value.
Constraint: n>0.
ifail=-99
An unexpected error has been triggered by this routine. Please contact NAG.
See Section 7 in the Introduction to the NAG Library FL Interface for further information.
ifail=-399
Your licence key may have expired or may not have been installed correctly.
See Section 8 in the Introduction to the NAG Library FL Interface for further information.
ifail=-999
Dynamic memory allocation failed.
See Section 9 in the Introduction to the NAG Library FL Interface for further information.

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.0p<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(2n-1)|+|g(2n)|), 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.
Note that if p=1, y1 is returned. If p=−1 and n>1, y−1 is returned. In these cases, no interpolation is necessary and there is no loss of accuracy.

8 Parallelism and Performance

e01abf is not threaded in any implementation.

9 Further Comments

The computation time increases as the order of n increases.

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

10.1 Program Text

Program Text (e01abfe.f90)

10.2 Program Data

Program Data (e01abfe.d)

10.3 Program Results

Program Results (e01abfe.r)