NAG Library Routine Document

e02bdf  (dim1_spline_integ)

 Contents

    1  Purpose
    7  Accuracy

1
Purpose

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

2
Specification

Fortran Interface
Subroutine e02bdf ( ncap7, lamda, c, dint, ifail)
Integer, Intent (In):: ncap7
Integer, Intent (Inout):: ifail
Real (Kind=nag_wp), Intent (In):: lamda(ncap7), c(ncap7)
Real (Kind=nag_wp), Intent (Out):: dint
C Header Interface
#include nagmk26.h
void  e02bdf_ ( const Integer *ncap7, const double lamda[], const double c[], double *dint, Integer *ifail)

3
Description

e02bdf 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 e02baf), 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).
e02bdf can be used to determine the definite integrals of cubic spline fits and interpolants produced by e02baf.

4
References

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

5
Arguments

1:     ncap7 – IntegerInput
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: ncap78.
2:     lamdancap7 – Real (Kind=nag_wp) arrayInput
On entry: 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.
3:     cncap7 – Real (Kind=nag_wp) arrayInput
On entry: the coefficient ci of the B-spline Nix, for i=1,2,,n-+3. The remaining elements of the array are not referenced.
4:     dint – Real (Kind=nag_wp)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.
5:     ifail – IntegerInput/Output
On entry: ifail must be set to 0, -1​ or ​1. If you are unfamiliar with this argument you should refer to Section 3.4 in How to Use the NAG Library and its Documentation for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value -1​ or ​1 is recommended. If the output of error messages is undesirable, then the value 1 is recommended. Otherwise, if you are not familiar with this argument, the recommended value is 0. When the value -1​ or ​1 is used it is essential to test the value of ifail on exit.
On exit: ifail=0 unless the routine detects an error or a warning has been flagged (see Section 6).

6
Error Indicators and Warnings

If on entry ifail=0 or -1, explanatory error messages are output on the current error message unit (as defined by x04aaf).
Errors or warnings detected by the routine:
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.
See Section 3.9 in How to Use the NAG Library and its Documentation for further information.
ifail=-399
Your licence key may have expired or may not have been installed correctly.
See Section 3.8 in How to Use the NAG Library and its Documentation for further information.
ifail=-999
Dynamic memory allocation failed.
See Section 3.7 in How to Use the NAG Library and its Documentation for further information.

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

e02bdf is not threaded in any implementation.

9
Further Comments

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-   
lamdaj, for j=1,2,,ncap7
cj, for j=1,2,,ncap7-3

10.1
Program Text

Program Text (e02bdfe.f90)

10.2
Program Data

Program Data (e02bdfe.d)

10.3
Program Results

Program Results (e02bdfe.r)

© The Numerical Algorithms Group Ltd, Oxford, UK. 2017