hide long namesshow long names
hide short namesshow short names
Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

NAG Toolbox: nag_interp_1d_everett (e01ab)

 Contents

    1  Purpose
    2  Syntax
    7  Accuracy
    9  Example

Purpose

nag_interp_1d_everett (e01ab) 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.

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:
At Mark 23: n1 is no longer an optional input parameter; n2 is no longer an input parameter

Description

nag_interp_1d_everett (e01ab) interpolates a function of one variable at a given point
x=x0+ph,  
where -1<p<1 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 function in addition to the interpolated function value yp.

References

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

Parameters

Compulsory Input Parameters

1:     n int64int32nag_int scalar
n, half the number of points to be used in the interpolation.
Constraint: n>0.
2:     p – double scalar
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.0<p<1.0.
3:     an1 – double array
ai must be set to the function value yi-n, for i=1,2,,2n.

Optional Input Parameters

None.

Output Parameters

1:     an1 – double array
n1=2×n.
The contents of a are unspecified.
2:     gn2 – double array
n2=2×n+1.
The array contains
δ2ry0in g1
δ2ry1in g2
δ2ry0in g2r+1
δ2ry1in g2r+2, for r=1,2,,n-1.
The interpolated function value yp is stored in g2n+1.
3:     ifail int64int32nag_int scalar
ifail=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
On entry,p-1.0,
orp1.0.
   ifail=-99
An unexpected error has been triggered by this routine. Please contact NAG.
   ifail=-399
Your licence key may have expired or may not have been installed correctly.
   ifail=-999
Dynamic memory allocation failed.

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×g2n-1+g2n, 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.

Further Comments

The computation time increases as the order of n increases.

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.
function e01ab_example


fprintf('e01ab example results\n\n');

a = [-1  -0.50   0    0.50    1    1.50];
b = [ 0  -0.53  -1   -0.46    2   11.09];
n = int64(size(a,2)/2);

x = 0.28;
% We get p from x = a(n) + p*h, where h = 0.5
p = (x-a(n))/0.5;

[bx, c, ifail] = e01ab(n, p, b);

for k = 0:n-1
  fprintf('Central differences order %4d of y_0 = %12.5f\n', k, c(2*k+1));
  fprintf('%37s = %12.5f\n', 'y_1',c(2*k+2));
end
fprintf('\nFunction value at interpolation point = %12.5f\n', c(end));


e01ab example results

Central differences order    0 of y_0 =     -1.00000
                                  y_1 =     -0.46000
Central differences order    1 of y_0 =      1.01000
                                  y_1 =      1.92000
Central differences order    2 of y_0 =     -0.04000
                                  y_1 =      3.80000

Function value at interpolation point =     -0.83591

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2015