NAG CL Interface
e02bdc (dim1_​spline_​integ)

1 Purpose

e02bdc computes the definite integral of a cubic spline from its B-spline representation.

2 Specification

#include <nag.h>
void  e02bdc (Nag_Spline *spline, double *integral, NagError *fail)
The function may be called by the names: e02bdc, nag_fit_dim1_spline_integ or nag_1d_spline_intg.

3 Description

e02bdc computes the definite integral of the cubic spline sx between the limits x=a and x=b, where a and b are respectively the lower and upper limits of the range over which sx is defined. It is assumed that sx is represented in terms of its B-spline coefficients ci, for i=1,2,,n¯+3 and (augmented) ordered knot set λi, for i=1,2,,n¯+7, with λi=a, for i=1,2,3,4 and λi=b, for i=n¯+4,,n¯+7, (see e02bac), i.e.,
sx=i=1qciNix.  
Here q=n¯+3, n¯ is the number of intervals of the spline and Nix denotes the normalized B-spline of degree 3 (order 4) defined upon the knots λi,λi+1,,λi+4.
The method employed uses the formula given in Section 3 of Cox (1975).
e02bdc can be used to determine the definite integrals of cubic spline fits and interpolants produced by e01bac, e02bac and e02bec.

4 References

Cox M G (1975) An algorithm for spline interpolation J. Inst. Math. Appl. 15 95–108

5 Arguments

1: spline Nag_Spline *
Pointer to structure of type Nag_Spline with the following members:
nIntegerInput
On entry: n ¯ + 7 , where n ¯ 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 a to b ) over which the spline is defined.
Constraint: splinen8 .
lamdadouble *Input
On entry: a pointer to which memory of size splinen must be allocated. splinelamda[j-1] must be set to the value of the j th member of the complete set of knots, λ j for j = 1 , 2 , , n ¯ + 7 .
Constraint: the λ j must be in nondecreasing order with splinelamda[splinen-4] > splinelamda[3] and satisfy
splinelamda[0] = splinelamda[1] = splinelamda[2] = splinelamda[3]
and
splinelamda[splinen-4] = splinelamda[splinen-3] =
splinelamda[splinen-2] = splinelamda[splinen-1]
cdouble *Input
On entry: a pointer to which memory of size splinen-4 must be allocated. splinec holds the coefficient c i of the B-spline N i x , for i = 1 , 2 , , n ¯ + 3 .
2: integral double * Output
On exit: the value of the definite integral of sx between the limits x=a and x=b, where a=λ4 and b=λn¯+4.
3: fail NagError * Input/Output
The NAG error argument (see Section 7 in the Introduction to the NAG Library CL Interface).

6 Error Indicators and Warnings

NE_INT_ARG_LT
On entry, splinen must not be less than 8: splinen=value .
NE_KNOTS_CONS
On entry, the knots must satisfy the following constraints:
splinelamda[splinen-4] > splinelamda[3] , splinelamda[j] splinelamda[j-1] , for j=1,2,,splinen - 1, with equality in the cases j = 1 , 2 , 3 , splinen-3 , splinen-2 and splinen-1 .

7 Accuracy

The rounding errors are such that the computed value of the integral is exact for a slightly perturbed set of B-spline coefficients ci differing in a relative sense from those supplied by no more than 2.2×n¯+3×machine precision.

8 Parallelism and Performance

e02bdc is not threaded in any implementation.

9 Further Comments

Under normal usage, the call to e02bdc will follow a call to e01bac, e02bac or e02bec. In that case, the structure spline will have been set up correctly for input to e02bdc.
The time taken is approximately proportional to n¯+7.

10 Example

This example determines the definite integral over the interval 0x6 of a cubic spline having 6 interior knots at the positions λ=1, 3, 3, 3, 4, 4, the 8 additional knots 0, 0, 0, 0, 6, 6, 6, 6, and the 10 B-spline coefficients 10, 12, 13, 15, 22, 26, 24, 18, 14, 12.
The input data items (using the notation of Section 5) comprise the following values in the order indicated:
n¯+7  
spline.lamdaj-1, for j=1,2,,spline.n
spline.cj-1, for j=1,2,,spline.n-3
The example program is written in a general form that will enable the definite integral of a cubic spline having an arbitrary number of knots to be computed. Any number of datasets may be supplied. The only changes required to the program relate to the size of spline.lamda and the storage allocated to spline.c within the structure spline.

10.1 Program Text

Program Text (e02bdce.c)

10.2 Program Data

Program Data (e02bdce.d)

10.3 Program Results

Program Results (e02bdce.r)