hide long namesshow long names
hide short namesshow short names
Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

NAG Toolbox: nag_fit_1dspline_integ (e02bd)

Purpose

nag_fit_1dspline_integ (e02bd) computes the definite integral of a cubic spline from its B-spline representation.

Syntax

[dint, ifail] = e02bd(lamda, c, 'ncap7', ncap7)
[dint, ifail] = nag_fit_1dspline_integ(lamda, c, 'ncap7', ncap7)

Description

nag_fit_1dspline_integ (e02bd) computes the definite integral of the cubic spline s(x)s(x) between the limits x = ax=a and x = bx=b, where aa and bb are respectively the lower and upper limits of the range over which s(x)s(x) is defined. It is assumed that s(x)s(x) is represented in terms of its B-spline coefficients cici, for i = 1,2,,n + 3i=1,2,,n-+3 and (augmented) ordered knot set λiλi, for i = 1,2,,n + 7i=1,2,,n-+7, with λi = aλi=a, for i = 1,2,3,4i=1,2,3,4 and λi = bλi=b, for i = n + 4,,n + 7i=n-+4,,n-+7, (see nag_fit_1dspline_knots (e02ba)), i.e.,
q
s(x) = ciNi(x).
i = 1
s(x)=i=1qciNi(x).
Here q = n + 3q=n-+3, nn- is the number of intervals of the spline and Ni(x)Ni(x) denotes the normalized B-spline of degree 33 (order 44) defined upon the knots λi,λi + 1,,λi + 4λi,λi+1,,λi+4.
The method employed uses the formula given in Section 3 of Cox (1975).
nag_fit_1dspline_integ (e02bd) can be used to determine the definite integrals of cubic spline fits and interpolants produced by nag_fit_1dspline_knots (e02ba).

References

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

Parameters

Compulsory Input Parameters

1:     lamda(ncap7) – double array
ncap7, the dimension of the array, must satisfy the constraint ncap78ncap78.
lamda(j)lamdaj must be set to the value of the jjth member of the complete set of knots, λjλj, for j = 1,2,,n + 7j=1,2,,n-+7.
Constraint: the lamda(j)lamdaj must be in nondecreasing order with lamda(ncap73) > lamda(4)lamdancap7-3> lamda4 and satisfy lamda(1) = lamda(2) = lamda(3) = lamda(4)lamda1=lamda2=lamda3=lamda4 and lamda(ncap73) = lamda(ncap72) = lamda(ncap71) = lamda(ncap7)lamdancap7-3=lamdancap7-2= lamdancap7-1=lamdancap7.
2:     c(ncap7) – double array
ncap7, the dimension of the array, must satisfy the constraint ncap78ncap78.
The coefficient cici of the B-spline Ni(x)Ni(x), for i = 1,2,,n + 3i=1,2,,n-+3. The remaining elements of the array are not referenced.

Optional Input Parameters

1:     ncap7 – int64int32nag_int scalar
Default: The dimension of the arrays lamda, c. (An error is raised if these dimensions are not equal.)
n + 7n-+7, where nn- 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 aa to bb) over which the spline is defined.
Constraint: ncap78ncap78.

Input Parameters Omitted from the MATLAB Interface

None.

Output Parameters

1:     dint – double scalar
The value of the definite integral of s(x)s(x) between the limits x = ax=a and x = bx=b, where a = λ4a=λ4 and b = λn + 4b=λn-+4.
2:     ifail – int64int32nag_int scalar
ifail = 0ifail=0 unless the function detects an error (see [Error Indicators and Warnings]).

Error Indicators and Warnings

Errors or warnings detected by the function:
  ifail = 1ifail=1
ncap7 < 8ncap7<8, i.e., the number of intervals is not positive.
  ifail = 2ifail=2
At least one of the following restrictions on the knots is violated: for j = 2,3,,ncap7j=2,3,,ncap7, with equality in the cases j = 2,3,4,ncap72,ncap71j=2,3,4,ncap7-2,ncap7-1, and ncap7

Accuracy

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

Further Comments

The time taken is approximately proportional to n + 7n-+7.

Example

function nag_fit_1dspline_integ_example
lamda = [0;
     0;
     0;
     0;
     1;
     3;
     3;
     3;
     4;
     4;
     6;
     6;
     6;
     6];
c = [10;
     12;
     13;
     15;
     22;
     26;
     24;
     18;
     14;
     12;
     0;
     0;
     0;
     0];
[dint, ifail] = nag_fit_1dspline_integ(lamda, c)
 

dint =

   100


ifail =

                    0


function e02bd_example
lamda = [0;
     0;
     0;
     0;
     1;
     3;
     3;
     3;
     4;
     4;
     6;
     6;
     6;
     6];
c = [10;
     12;
     13;
     15;
     22;
     26;
     24;
     18;
     14;
     12;
     0;
     0;
     0;
     0];
[dint, ifail] = e02bd(lamda, c)
 

dint =

   100


ifail =

                    0



PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2013