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)

Purpose

nag_interp_1d_everett (e01ab) interpolates a function of one variable at a given point xx 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<p<1 and hh is the interval of differencing, from a table of values xm = x0 + mhxm=x0+mh and ymym where m = (n1),(n2),,1,0,1,,nm=-(n-1),-(n-2),,-1,0,1,,n. The formula used is that of Fröberg (1970), neglecting the remainder term:
n1 n1
yp = ((1p + 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δ2ry0 and δ2ry1δ2ry1 are stored on exit from the function in addition to the interpolated function value ypyp.

References

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

Parameters

Compulsory Input Parameters

1:     n – int64int32nag_int scalar
nn, half the number of points to be used in the interpolation.
Constraint: n > 0n>0.
2:     p – double scalar
The point pp at which the interpolated function value is required, i.e., p = (xx0) / hp=(x-x0)/h with 1.0 < p < 1.0-1.0<p<1.0.
Constraint: 1.0 < p < 1.0-1.0<p<1.0.
3:     a(n1) – double array
a(i)ai must be set to the function value yinyi-n, for i = 1,2,,2ni=1,2,,2n.

Optional Input Parameters

None.

Input Parameters Omitted from the MATLAB Interface

n1 n2

Output Parameters

1:     a(n1) – double array
n1 = 2 × nn1=2×n.
The contents of a are unspecified.
2:     g(n2) – double array
n2 = 2 × n + 1n2=2×n+1.
The array contains
δ2ry0δ2ry0 in g(1)g1
δ2ry1δ2ry1 in g(2)g2
δ2ry0δ2ry0 in g(2r + 1)g2r+1
δ2ry1δ2ry1 in g(2r + 2)g2r+2, for r = 1,2,,n1r=1,2,,n-1.
The interpolated function value ypyp is stored in g(2n + 1)g2n+1.
3:     ifail – int64int32nag_int scalar
ifail = 0ifail=0 unless the function detects an error (see [Error Indicators and Warnings]).

Error Indicators and Warnings

Errors or warnings detected by the function:
  ifail = 1ifail=1
On entry,p1.0p-1.0,
orp1.0p1.0.

Accuracy

In general, increasing nn improves the accuracy of the result until full attainable accuracy is reached, after which it might deteriorate. If xx lies in the central interval of the data (i.e., 0.0p < 1.00.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(2n1)| + |g(2n)|)a×(|g2n-1|+|g2n|), where a = 0.1a=0.1, 0.020.02, 0.0050.005, 0.0010.001, 0.00020.0002 for n = 1,2,3,4,5n=1,2,3,4,5 respectively, thereafter decreasing roughly by a factor of 44 each time.

Further Comments

The computation time increases as the order of nn 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



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–2013