NAG CL Interfacee02bdc (dim1_​spline_​integ)

Settings help

CL Name Style:

1Purpose

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

2Specification

 #include
 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.

3Description

e02bdc computes the definite integral of the cubic spline $s\left(x\right)$ between the limits $x=a$ and $x=b$, where $a$ and $b$ are respectively the lower and upper limits of the range over which $s\left(x\right)$ is defined. It is assumed that $s\left(x\right)$ is represented in terms of its B-spline coefficients ${c}_{i}$, for $\mathit{i}=1,2,\dots ,\overline{n}+3$ and (augmented) ordered knot set ${\lambda }_{i}$, for $\mathit{i}=1,2,\dots ,\overline{n}+7$, with ${\lambda }_{i}=a$, for $\mathit{i}=1,2,3,4$ and ${\lambda }_{i}=b$, for $\mathit{i}=\overline{n}+4,\dots ,\overline{n}+7$, (see e02bac), i.e.,
 $s(x)=∑i=1qciNi(x).$
Here $q=\overline{n}+3$, $\overline{n}$ is the number of intervals of the spline and ${N}_{i}\left(x\right)$ denotes the normalized B-spline of degree $3$ (order $4$) defined upon the knots ${\lambda }_{i},{\lambda }_{i+1},\dots ,{\lambda }_{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.

4References

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

5Arguments

1: $\mathbf{spline}$Nag_Spline *
Pointer to structure of type Nag_Spline with the following members:
nIntegerInput
On entry: $\overline{n}+7$, where $\overline{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: $\mathbf{spline}\mathbf{\to }\mathbf{n}\ge 8$.
On entry: a pointer to which memory of size $\mathbf{spline}\mathbf{\to }\mathbf{n}$ must be allocated. $\mathbf{spline}\mathbf{\to }\mathbf{lamda}\left[j-1\right]$ must be set to the value of the $j$th member of the complete set of knots, ${\lambda }_{j}$ for $j=1,2,\dots ,\overline{n}+7$.
Constraint: the ${\lambda }_{j}$ must be in nondecreasing order with $\mathbf{spline}\mathbf{\to }\mathbf{lamda}\left[\mathbf{spline}\mathbf{\to }\mathbf{n}-4\right]>\mathbf{spline}\mathbf{\to }\mathbf{lamda}\left[3\right]$ and satisfy
$\mathbf{spline}\mathbf{\to }\mathbf{lamda}\left[0\right]=\mathbf{spline}\mathbf{\to }\mathbf{lamda}\left[1\right]=\mathbf{spline}\mathbf{\to }\mathbf{lamda}\left[2\right]=\mathbf{spline}\mathbf{\to }\mathbf{lamda}\left[3\right]$
and
$\mathbf{spline}\mathbf{\to }\mathbf{lamda}\left[\mathbf{spline}\mathbf{\to }\mathbf{n}-4\right]=\mathbf{spline}\mathbf{\to }\mathbf{lamda}\left[\mathbf{spline}\mathbf{\to }\mathbf{n}-3\right]=$
$\phantom{\rule{2em}{0ex}}\mathbf{spline}\mathbf{\to }\mathbf{lamda}\left[\mathbf{spline}\mathbf{\to }\mathbf{n}-2\right]=\mathbf{spline}\mathbf{\to }\mathbf{lamda}\left[\mathbf{spline}\mathbf{\to }\mathbf{n}-1\right]$
cdouble *Input
On entry: a pointer to which memory of size $\mathbf{spline}\mathbf{\to }\mathbf{n}-4$ must be allocated. $\mathbf{spline}\mathbf{\to }\mathbf{c}$ holds the coefficient ${c}_{i}$ of the B-spline ${N}_{i}\left(x\right)$, for $i=1,2,\dots ,\overline{n}+3$.
2: $\mathbf{integral}$double * Output
On exit: the value of the definite integral of $s\left(x\right)$ between the limits $x=a$ and $x=b$, where $a={\lambda }_{4}$ and $b={\lambda }_{\overline{n}+4}$.
3: $\mathbf{fail}$NagError * Input/Output
The NAG error argument (see Section 7 in the Introduction to the NAG Library CL Interface).

6Error Indicators and Warnings

NE_INT_ARG_LT
On entry, $\mathbf{spline}\mathbf{\to }\mathbf{n}$ must not be less than 8: $\mathbf{spline}\mathbf{\to }\mathbf{n}=⟨\mathit{\text{value}}⟩$.
NE_KNOTS_CONS
On entry, the knots must satisfy the following constraints:
$\mathbf{spline}\mathbf{\to }\mathbf{lamda}\left[\mathbf{spline}\mathbf{\to }\mathbf{n}-4\right]>\mathbf{spline}\mathbf{\to }\mathbf{lamda}\left[3\right]$, $\mathbf{spline}\mathbf{\to }\mathbf{lamda}\left[\mathit{j}\right]\ge \mathbf{spline}\mathbf{\to }\mathbf{lamda}\left[\mathit{j}-1\right]$, for $\mathit{j}=1,2,\dots ,\mathbf{spline}\mathbf{\to }\mathbf{n}-1$, with equality in the cases $j=1,2,3$, $\mathbf{spline}\mathbf{\to }\mathbf{n}-3$, $\mathbf{spline}\mathbf{\to }\mathbf{n}-2$ and $\mathbf{spline}\mathbf{\to }\mathbf{n}-1$.

7Accuracy

The rounding errors are such that the computed value of the integral is exact for a slightly perturbed set of B-spline coefficients ${c}_{i}$ differing in a relative sense from those supplied by no more than .

8Parallelism and Performance

e02bdc is not threaded in any implementation.

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 $\overline{n}+7$.

10Example

This example determines the definite integral over the interval $0\le x\le 6$ of a cubic spline having $6$ interior knots at the positions $\lambda =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:
$\overline{\mathbit{n}}+7$
${\mathbf{spline}}\mathbf{.}\mathbf{lamda}\left[j-1\right]$, for $j=1,2,\dots ,{\mathbf{spline}}\mathbf{.}\mathbf{n}$
${\mathbf{spline}}\mathbf{.}\mathbf{c}\left[j-1\right]$, for $j=1,2,\dots ,{\mathbf{spline}}\mathbf{.}\mathbf{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 ${\mathbf{spline}}\mathbf{.}\mathbf{lamda}$ and the storage allocated to ${\mathbf{spline}}\mathbf{.}\mathbf{c}$ within the structure spline.

10.1Program Text

Program Text (e02bdce.c)

10.2Program Data

Program Data (e02bdce.d)

10.3Program Results

Program Results (e02bdce.r)