|
NAG[e01bac] NAG[nag_1d_spline_interpolant] - Interpolating function, cubic spline interpolant, one variable
|
|
Calling Sequence
e01bac(x, y, spline_data, 'm'=m, 'fail'=fail)
nag_1d_spline_interpolant(. . .)
Parameters
|
x - Vector(1..m, datatype=float[8]);
|
|
|
Constraint: , for . .
|
|
|
y - Vector(1..m, datatype=float[8]);
|
|
|
|
spline_data - table;
|
|
|
A Maple table, which should be generated using NAG[Nag_Spline], corresponding to the Nag_Spline structure.
|
|
On exit: the size of the storage internally allocated to lamda and c. This is set to .
|
|
|
'm'=m - integer; (optional)
|
|
|
Default value: the first dimension of the arrays x, y.
|
|
On entry: , the number of data points.
|
|
Constraint: . .
|
|
|
'fail'=fail - table; (optional)
|
|
|
The NAG error argument, see the documentation for NagError.
|
|
|
|
Description
|
|
|
Purpose
|
|
nag_1d_spline_interpolant (e01bac) determines a cubic spline interpolant to a given set of data.
|
|
Description
|
|
nag_1d_spline_interpolant (e01bac) determines a cubic spline , defined in the range , which interpolates (passes exactly through) the set of data points , for , where and . Unlike some other spline interpolation algorithms, derivative end conditions are not imposed. The spline interpolant chosen has interior knots , which are set to the values of respectively. This spline is represented in its B-spline form (see Cox (1975a)):
where denotes the normalized B-spline of degree 3, defined upon the knots , and denotes its coefficient, whose value is to be determined by the function.
The use of B-splines requires eight additional knots , , , , , , and to be specified; the function sets the first four of these to and the last four to .
The algorithm for determining the coefficients is as described in Cox (1975a) except that factorization is used instead of decomposition. The implementation of the algorithm involves setting up appropriate information for the related function e02bac (nag_1d_spline_fit_knots) followed by a call of that function. (For further details of e02bac (nag_1d_spline_fit_knots), see the function document.)
Values of the spline interpolant, or of its derivatives or definite integral, can subsequently be computed as detailed in Section [Further Comments].
|
|
Error Indicators and Warnings
|
|
"NE_ALLOC_FAIL"
Dynamic memory allocation failed.
"NE_INT_ARG_LT"
On entry, m must not be less than 4: .
"NE_NOT_STRICTLY_INCREASING"
The sequence x is not strictly increasing: , .
|
|
Accuracy
|
|
The rounding errors incurred are such that the computed spline is an exact interpolant for a slightly perturbed set of ordinates . The ratio of the root-mean-square value of the to that of the is no greater than a small multiple of the relative machine precision.
|
|
Further Comments
|
|
The time taken by nag_1d_spline_interpolant (e01bac) is approximately proportional to .
All the are used as knot positions except and . This choice of knots (see Cox (1977)) means that is composed of cubic arcs as follows. If , there is just a single arc space spanning the whole interval to . If , the first and last arcs span the intervals to and to respectively. Additionally if , the th arc, for spans the interval to .
After the call
e01bac(x, y, spline)
the following operations may be carried out on the interpolant .
The value of at can be provided in the variable sval by calling the function
e02bbc(xval, sval, spline)
The values of and its first three derivatives at can be provided in the array sdif of dimension 4, by the call
e02bcc(derivs, xval, sdif, spline)
Here derivs must specify whether the left- or right-hand value of the third derivative is required (see e02bcc (nag_1d_spline_deriv) for details). The value of the integral of over the range to can be provided in the variable sint by
e02bdc(spline, sint)
|
|
|
Examples
|
|
>
|
m := 7:
spline_data := NAG:-Nag_Spline():
x := Vector([0, 0.2, 0.4, 0.6, 0.75, 0.9, 1], datatype=float[8]):
y := Vector([1, 1.22140275816017, 1.49182469764127, 1.822118800390509, 2.117000016612675, 2.45960311115695, 2.718281828459045], datatype=float[8]):
NAG:-e01bac(x, y, spline_data, 'm' = m):
spline_data['n']:
spline_data['lamda']:
spline_data['c'][1..m]:
|
|
|
See Also
|
|
Cox M G (1975a) An algorithm for spline interpolation J. Inst. Math. Appl. 15 95–108
Cox M G (1977) A survey of numerical methods for data and function approximation The State of the Art in Numerical Analysis (ed D A H Jacobs) 627–668 Academic Press
e01 Chapter Introduction.
NAG Toolbox Overview.
NAG Web Site.
|
|