​spline_​deriv, c, x, left)[source]

dim1_spline_deriv evaluates a cubic spline and its first three derivatives from its B-spline representation.

For full information please refer to the NAG Library document for e02bc

lamdafloat, array-like, shape

must be set to the value of the th member of the complete set of knots, , for .

cfloat, array-like, shape

The coefficient of the B-spline , for . The remaining elements of the array are not referenced.


The argument at which the cubic spline and its derivatives are to be evaluated.


Specifies whether left- or right-hand values of the spline and its derivatives are to be computed (see Notes). Left - or right-hand values are formed according to whether is equal or not equal to .

If does not coincide with a knot, the value of is immaterial.

If , right-hand values are computed.

If , left-hand values are formed, regardless of the value of .

sfloat, ndarray, shape

contains the value of the th derivative of the spline at the argument , for . Note that contains the value of the spline.

(errno )

On entry, .

Constraint: .

(errno )

On entry, , and .

Constraint: .

(errno )

On entry, and .

Constraint: .

(errno )

On entry, , and .

Constraint: .


In the NAG Library the traditional C interface for this routine uses a different algorithmic base. Please contact NAG if you have any questions about compatibility.

dim1_spline_deriv 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 dim1_spline_knots()), 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:

  1. carrying out a binary search for the knot interval containing the argument (see Cox (1978)),

  2. evaluating the nonzero B-splines of orders , , and by recurrence (see Cox (1972) and Cox (1978)),

  3. computing all derivatives of the B-splines of order by applying a second recurrence to these computed B-spline values (see de Boor (1972)),

  4. 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.

dim1_spline_deriv can be used to compute the values and derivatives of cubic spline fits and interpolants produced by dim1_spline_knots().

If only values and not derivatives are required, dim1_spline_eval() may be used instead of dim1_spline_deriv, which takes about longer than dim1_spline_eval().


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. Theory (6), 50–62