CSITG
This function evaluates the integral of a cubic spline.
Function Return Value
CSITG — Value of the integral of the spline from A to B. (Output)
Required Arguments
A — Lower limit of integration. (Input)
B — Upper limit of integration. (Input)
BREAK — Array of length NINTV + 1 containing the breakpoints for the piecewise cubic representation. (Input)
BREAK must be strictly increasing.
CSCOEF — Matrix of size 4 by NINTV + 1 containing the local coefficients of the cubic pieces. (Input)
Optional Arguments
NINTV — Number of polynomial pieces. (Input)
Default: NINTV = size (BREAK,1) - 1.
FORTRAN 90 Interface
Generic: CSITG (A, B, BREAK, CSCOEF [])
Specific: The specific interface names are S_CSITG and D_CSITG.
FORTRAN 77 Interface
Single: CSITG(A, B, NINTV, BREAK, CSCOEF)
Double: The double precision function name is DCSITG.
Description
The function CSITG evaluates the integral of a cubic spline over an interval. It is a special case of the routine PPITG, which evaluates the integral of a piecewise polynomial. (A cubic spline is a piecewise polynomial of order 4.)
Example
This example computes a cubic spline interpolant to the function x2 using CSINT and evaluates its integral over the intervals [0., .5] and [0., 2.]. Since CSINT uses the not-a knot condition, the interpolant reproduces x2, hence the integral values are 1/24 and 8/3, respectively.

USE CSITG_INT
USE UMACH_INT
USE CSINT_INT

IMPLICIT NONE
INTEGER NDATA
PARAMETER (NDATA=10)
!
INTEGER I, NINTV, NOUT
REAL A, B, BREAK(NDATA), CSCOEF(4,NDATA), ERROR,&
EXACT, F, FDATA(NDATA), FI, FLOAT, VALUE, X,&
XDATA(NDATA)
INTRINSIC FLOAT
! Define function and integral
F(X) = X*X
FI(X) = X*X*X/3.0
! Set up a grid
DO 10 I=1, NDATA
XDATA(I) = FLOAT(I-1)/FLOAT(NDATA-1)
FDATA(I) = F(XDATA(I))
10 CONTINUE
! Compute cubic spline interpolant
CALL CSINT (XDATA, FDATA, BREAK, CSCOEF)
! Compute the integral of F over
! [0.0,0.5]
A = 0.0
B = 0.5
NINTV = NDATA - 1
VALUE = CSITG(A,B,BREAK,CSCOEF)
EXACT = FI(B) - FI(A)
ERROR = EXACT - VALUE
! Get output unit number
CALL UMACH (2, NOUT)
! Print the result
WRITE (NOUT,99999) A, B, VALUE, EXACT, ERROR
! Compute the integral of F over
! [0.0,2.0]
A = 0.0
B = 2.0
VALUE = CSITG(A,B,BREAK,CSCOEF)
EXACT = FI(B) - FI(A)
ERROR = EXACT - VALUE
! Print the result
WRITE (NOUT,99999) A, B, VALUE, EXACT, ERROR
99999 FORMAT (' On the closed interval (', F3.1, ',', F3.1,&
') we have :', /, 1X, 'Computed Integral = ', F10.5, /,&
1X, 'Exact Integral = ', F10.5, /, 1X, 'Error '&
, ' = ', F10.6, /, /)
END
Output

On the closed interval (0.0,0.5) we have :
Computed Integral = 0.04167
Exact Integral = 0.04167
Error = 0.000000

On the closed interval (0.0,2.0) we have :
Computed Integral = 2.66666
Exact Integral = 2.66667
Error = 0.000006