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)

 Contents

    1  Purpose
    2  Syntax
    7  Accuracy
    9  Example

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 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 nag_fit_1dspline_knots (e02ba)), 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).
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:     lamdancap7 – double array
lamdaj must be set to the value of the jth member of the complete set of knots, λj, for j=1,2,,n-+7.
Constraint: the lamdaj must be in nondecreasing order with lamdancap7-3> lamda4 and satisfy lamda1=lamda2=lamda3=lamda4 and lamdancap7-3=lamdancap7-2= lamdancap7-1=lamdancap7.
2:     cncap7 – double array
The coefficient ci of the B-spline Nix, for i=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-+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: ncap78.

Output Parameters

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

Error Indicators and Warnings

Errors or warnings detected by the function:
   ifail=1
ncap7<8, i.e., the number of intervals is not positive.
   ifail=2
At least one of the following restrictions on the knots is violated:
  • lamdancap7-3>lamda4,
  • lamdajlamdaj-1,
for j=2,3,,ncap7, with equality in the cases j=2,3,4,ncap7-2,ncap7-1, and ncap7
   ifail=-99
An unexpected error has been triggered by this routine. Please contact NAG.
   ifail=-399
Your licence key may have expired or may not have been installed correctly.
   ifail=-999
Dynamic memory allocation failed.

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.

Further Comments

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

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 Arguments) comprise the following values in the order indicated:
n-   
lamdaj, for j=1,2,,ncap7
cj, for j=1,2,,ncap7-3
function e02bd_example


fprintf('e02bd example results\n\n');

knots = [ 1  3  3  3  4  4];
ncap = size(knots,2) + 1;
ncap7 = ncap + 7;

lamda = zeros(ncap7,1);
lamda(5:ncap+3) = knots;
lamda(ncap+4:ncap7) = 6;

% B-spline coefficients
c = zeros(ncap7,1);
c(1:ncap+3) = [10  12  13  15  22  26  24  18  14  12];

[dint, ifail] = e02bd( ...
                       lamda, c);

fprintf('Definite integral = %10.3e\n',dint);


e02bd example results

Definite integral =  1.000e+02

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–2015