NAG Library Function Document
nag_1d_spline_intg (e02bdc)
1 Purpose
nag_1d_spline_intg (e02bdc) computes the definite integral of a cubic spline from its B-spline representation.
2 Specification
#include <nag.h> |
#include <nage02.h> |
|
3 Description
nag_1d_spline_intg (e02bdc) computes the definite integral of the cubic spline
between the limits
and
, where
and
are respectively the lower and upper limits of the range over which
is defined. It is assumed that
is represented in terms of its B-spline coefficients
, for
and (augmented) ordered knot set
, for
, with
, for
and
, for
, (see
nag_1d_spline_fit_knots (e02bac)), 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 method employed uses the formula given in Section 3 of
Cox (1975).
nag_1d_spline_intg (e02bdc) can be used to determine the definite integrals of cubic spline fits and interpolants produced by
nag_1d_spline_interpolant (e01bac),
nag_1d_spline_fit_knots (e02bac) and
nag_1d_spline_fit (e02bec).
4 References
Cox M G (1975) An algorithm for spline interpolation J. Inst. Math. Appl. 15 95–108
5 Arguments
- 1:
– 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 – double *Input
-
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
and satisfy
and
- c – double *Input
-
On entry: a pointer to which memory of size must be allocated. holds the coefficient of the B-spline , for .
- 2:
– double *Output
-
On exit: the value of the definite integral of between the limits and , where and .
- 3:
– NagError *Input/Output
-
The NAG error argument (see
Section 3.6 in the Essential Introduction).
6 Error Indicators and Warnings
- NE_INT_ARG_LT
-
On entry, must not be less than 8: .
- NE_KNOTS_CONS
-
On entry, the knots must satisfy the following constraints:
, , for , with equality in the cases , , and .
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 differing in a relative sense from those supplied by no more than .
8 Parallelism and Performance
Not applicable.
Under normal usage, the call to nag_1d_spline_intg (e02bdc) will follow a call to
nag_1d_spline_interpolant (e01bac),
nag_1d_spline_fit_knots (e02bac) or
nag_1d_spline_fit (e02bec). In that case, the structure
spline will have been set up correctly for input to nag_1d_spline_intg (e02bdc).
The time taken is approximately proportional to .
10 Example
This example determines the definite integral over the interval of a cubic spline having interior knots at the positions , , , , , , 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 |
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
and the storage allocated to
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)