The function may be called by the names: e01bac, nag_interp_dim1_spline or 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 (1975)):
where denotes the normalized B-spline of degree , 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 (1975) except that factorization is used instead of decomposition. The implementation of the algorithm involves setting up appropriate information for the related function e02bac followed by a call of that function. (For further details of e02bac, see the function document.)
Values of the spline interpolant, or of its derivatives or definite integral, can subsequently be computed as detailed in Section 9.
Cox M G (1975) 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
1: – IntegerInput
On entry: , the number of data points.
2: – const doubleInput
On entry: must be set to , the th data value of the independent variable , for .
, for .
3: – const doubleInput
On entry: must be set to , the th data value of the dependent variable , for .
4: – Nag_Spline *
Pointer to structure of type Nag_Spline with the following members:
n – IntegerOutput
On exit: the size of the storage internally allocated to . This is set to .
lamda – double *Output
On exit: the pointer to which storage of size is internally allocated. contains the th knot, for .
c – double *Output
On exit: the pointer to which storage of size is internally allocated. contains the coefficient of the B-spline , for .
Note that when the information contained in the pointers and is no longer of use, or before a new call to e01bac with the same spline, you should free this storage using the NAG macro NAG_FREE. This storage will not have been allocated if this function returns with NE_NOERROR.
5: – NagError *Input/Output
The NAG error argument (see Section 7 in the Introduction to the NAG Library CL Interface).
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.
8Parallelism and Performance
Background information to multithreading can be found in the Multithreading documentation.
e01bac is not threaded in any implementation.
The time taken by 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(m, x, y, &spline, &fail)
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, &fail)
The values of and its first three derivatives at can be provided in the array sdif of dimension , by the call
e02bcc(derivs, xval, sdif, &spline, &fail)
Here derivs must specify whether the left- or right-hand value of the third derivative is required (see e02bcc for details). The value of the integral of over the range to can be provided in the variable sint by
e02bdc(&spline, &sint, &fail)
The following example program sets up data from 7 values of the exponential function in the interval 0 to . e01bac is then called to compute a spline interpolant to these data.
The spline is evaluated by e02bbc, at the data points and at points halfway between each adjacent pair of data points, and the spline values and the values of are printed out.