The routine may be called by the names e02bcf or nagf_fit_dim1_spline_deriv.
3Description
e02bcf evaluates the cubic spline and its first three derivatives at a prescribed argument . It is assumed that is represented in terms of its B-spline coefficients , for and (augmented) ordered knot set , for ,
(see e02baf),
i.e.,
Here , is the number of intervals of the spline and denotes the normalized B-spline of degree (order ) defined upon the knots . The prescribed argument must satisfy
At a simple knot (i.e., one satisfying ), the third derivative of the spline is in general discontinuous. At a multiple knot (i.e., two or more knots with the same value), lower derivatives, and even the spline itself, may be discontinuous. Specifically, at a point where (exactly) knots coincide (such a point is termed a knot of multiplicity ), the values of the derivatives of order , for , are in general discontinuous. (Here ; is not meaningful.) You must specify whether the value at such a point is required to be the left- or right-hand derivative.
The method employed is based upon:
(i)carrying out a binary search for the knot interval containing the argument (see Cox (1978)),
(ii)evaluating the nonzero B-splines of orders , , and by recurrence (see Cox (1972) and Cox (1978)),
(iii)computing all derivatives of the B-splines of order by applying a second recurrence to these computed B-spline values (see de Boor (1972)),
(iv)multiplying the fourth-order B-spline values and their derivative by the appropriate B-spline coefficients, and summing, to yield the values of and its derivatives.
e02bcf can be used to compute the values and derivatives of cubic spline fits and interpolants produced by
e02baf.
If only values and not derivatives are required, e02bbf may be used instead of e02bcf, which takes about longer than e02bbf.
4References
Cox M G (1972) The numerical evaluation of B-splines J. Inst. Math. Appl.10 134–149
Cox M G (1978) The numerical evaluation of a spline from its B-spline representation J. Inst. Math. Appl.21 135–143
de Boor C (1972) On calculating with B-splines J. Approx. Theory6 50–62
5Arguments
1: – IntegerInput
On entry: , where is the number of intervals of the spline (which is one greater than the number of interior knots, i.e., the knots strictly within the range to over which the spline is defined).
Constraint:
.
2: – Real (Kind=nag_wp) arrayInput
On entry: must be set to the value of the th member of the complete set of knots, , for .
Constraint:
the must be in nondecreasing order with .
3: – Real (Kind=nag_wp) arrayInput
On entry: the coefficient
of the B-spline , for . The remaining elements of the array are not referenced.
4: – Real (Kind=nag_wp)Input
On entry: the argument at which the cubic spline and its derivatives are to be evaluated.
Constraint:
.
5: – IntegerInput
On entry: specifies whether left- or right-hand values of the spline and its derivatives are to be computed (see Section 3). Left- or right-hand values are formed according to whether left is equal or not equal to .
If does not coincide with a knot, the value of left is immaterial.
If , right-hand values are computed.
If , left-hand values are formed, regardless of the value of left.
6: – Real (Kind=nag_wp) arrayOutput
On exit: contains the value of the th derivative of the spline at the argument , for . Note that contains the value of the spline.
7: – IntegerInput/Output
On entry: ifail must be set to , or to set behaviour on detection of an error; these values have no effect when no error is detected.
A value of causes the printing of an error message and program execution will be halted; otherwise program execution continues. A value of means that an error message is printed while a value of means that it is not.
If halting is not appropriate, the value or is recommended. If message printing is undesirable, then the value is recommended. Otherwise, the value is recommended. When the value or is used it is essential to test the value of ifail on exit.
On exit: unless the routine detects an error or a warning has been flagged (see Section 6).
6Error Indicators and Warnings
If on entry or , explanatory error messages are output on the current error message unit (as defined by x04aaf).
Errors or warnings detected by the routine:
On entry, .
Constraint: .
On entry, , and .
Constraint: .
On entry, , and .
Constraint: .
On entry, and .
Constraint: .
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.
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.
Dynamic memory allocation failed.
See Section 9 in the Introduction to the NAG Library FL Interface for further information.
7Accuracy
The computed value of has negligible error in most practical situations. Specifically, this value has an absolute error bounded in modulus by , where is the largest in modulus of and , and is an integer such that . If and are all of the same sign, then the computed value of has relative error bounded by . For full details see Cox (1978).
No complete error analysis is available for the computation of the derivatives of . However, for most practical purposes the absolute errors in the computed derivatives should be small.
8Parallelism and Performance
Background information to multithreading can be found in the Multithreading documentation.
e02bcf is not threaded in any implementation.
9Further Comments
The time taken is approximately linear in .
Note: the routine does not test all the conditions on the knots given in the description of lamda in Section 5, since to do this would result in a computation time approximately linear in instead of . All the conditions are tested in e02baf, however.
10Example
Compute, at the arguments
,
,
,
,
,
,
,
the left- and right-hand values and first derivatives of the cubic spline defined over the interval having the interior knots
,
,
,
,
,
, the additional knots
,
,
,
,
,
,
,
, and the B-spline coefficients
,
,
,
,
,
,
,
,
,
.
The input data items (using the notation of Section 5) comprise the following values in the order indicated:
,
for
,
for
,
for
This example program is written in a general form that will enable the values and derivatives of a cubic spline having an arbitrary number of knots to be evaluated at a set of arbitrary points. Any number of datasets may be supplied.
The only changes required to the program relate to the dimensions of the arrays lamda and c.