The function may be called by the names: e02bcc, nag_fit_dim1_spline_deriv or nag_1d_spline_deriv.
3Description
e02bcc 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 e02bac), i.e.,
Here , is the number of intervals of the spline and denotes the normalized B-spline of degree 3 (order 4) 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 th-order B-spline values and their derivative by the appropriate B-spline coefficients, and summing, to yield the values of and its derivatives.
e02bcc can be used to compute the values and derivatives of cubic spline fits and interpolants produced by e02bac, e02bec or e01bac.
If only values and not derivatives are required, e02bbc may be used instead of e02bcc, which takes about 50% longer than e02bbc.
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: – Nag_DerivTypeInput
On entry: derivs, of type Nag_DerivType, 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 derivs is equal to or respectively. If does not coincide with a knot, the value of derivs is immaterial. If , right-hand values are computed, and if ), left-hand values are formed, regardless of the value of derivs.
Constraint:
or .
2: – doubleInput
On entry: the argument at which the cubic spline and its derivatives are to be evaluated.
Constraint:
.
3: – doubleOutput
On exit: contains the value of the th derivative of the spline at the argument , for . Note that contains the value of the spline.
4: – Nag_Spline *
Pointer to structure of type Nag_Spline with the following members:
n – 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:
.
lamda – doubleInput
On entry: a pointer to which memory of size must be allocated. 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 .
c – doubleInput
On entry: a pointer to which memory of size must be allocated. holds the coefficient of the B-spline , for .
Under normal usage, the call to e02bcc will follow a call to e02bac, e01bac or e02bec. In that case, the structure spline will have been set up correctly for input to e02bcc.
5: – NagError *Input/Output
The NAG error argument (see Section 7 in the Introduction to the NAG Library CL Interface).
On entry, the cubic spline range is invalid:
while .
These must satisfy .
7Accuracy
The computed value of has negligible error in most practical situations. Specifically, this value has an absolute error bounded in modulus by machine precision, 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 machine precision. 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
e02bcc is not threaded in any implementation.
9Further Comments
The time taken by this function is approximately linear in .
Note: the function does not test all the conditions on the knots given in the description of in Section 5, since to do this would result in a computation time approximately linear in instead of . All the conditions are tested in e02bac, however, and the knots returned by e01bac or e02bec will satisfy the conditions.
10Example
Compute, at the 7 arguments , , , , , , , the left- and right-hand values and first 3 derivatives of the cubic spline defined over the interval having the 6 interior knots , , , , , , the 8 additional knots , , , , , , , , and the 10 B-spline coefficients , , , , , , , , , 12.
The input data items (using the notation of Section 5) comprise the following values in the order indicated:
The 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.