BSDER
This function evaluates the derivative of a spline, given its B-spline representation.
Function Return Value
BSDER — Value of the IDERIV-th derivative of the spline at X. (Output)
Required Arguments
IDERIV — Order of the derivative to be evaluated. (Input)
In particular, IDERIV = 0 returns the value of the spline.
X — Point at which the spline is to be evaluated. (Input)
KORDER — Order of the spline. (Input)
XKNOT — Array of length NCOEF + KORDER containing the knot sequence. (Input)
XKNOT must be nondecreasing.
NCOEF — Number of B-spline coefficients. (Input)
BSCOEF — Array of length NCOEF containing the B-spline coefficients. (Input)
FORTRAN 90 Interface
Generic: BSDER (IDERIV, X, KORDER, XKNOT, NCOEF, BSCOEF)
Specific: The specific interface names are S_BSDER and D_BSDER.
FORTRAN 77 Interface
Single: BSDER (IDERIV, X, KORDER, XKNOT, NCOEF, BSCOEF)
Double: The double precision function name is DBSDER.
Description
The function BSDER produces the value of a spline or one of its derivatives (given its B-spline representation) at a specific point. The function BSDER is based on the routine BVALUE by de Boor (1978, page 144).
Specifically, given the knot vector t, the number of coefficients N, the coefficient vector a, the order of the derivative i and a point x, BSDER returns the number
where Bj,k is the j-th B-spline of order k for the knot sequence t. Note that this function routine arbitrarily treats these functions as if they were right continuous near XKNOT(KORDER) and left continuous near XKNOT(NCOEF + 1). Thus, if we have KORDER knots stacked at the left or right end point, and if we try to evaluate at these end points, then we will get the value of the limit from the interior of the interval.
Comments
1. Workspace may be explicitly provided, if desired, by use of B2DER/DB2DER. The reference is:
CALL B2DER(IDERIV, X, KORDER, XKNOT, NCOEF, BSCOEF, WK1, WK2, WK3)
The additional arguments are as follows:
WK1 — Array of length KORDER.
WK2 — Array of length KORDER.
WK3 — Array of length KORDER.
2. Informational errors
Type
Code
Description
4
4
Multiplicity of the knots cannot exceed the order of the spline.
4
5
The knots must be nondecreasing.
Example
A spline interpolant to the function
is constructed using BSINT. The B-spline representation, which is returned by the IMSL routine BSINT, is then used by BSDER to compute the value and derivative of the interpolant. The output consists of the interpolation values and the error at the data points and the midpoints. In addition, we display the value of the derivative and the error at these same points.
 
USE BSDER_INT
USE BSINT_INT
USE BSNAK_INT
USE UMACH_INT
 
IMPLICIT NONE
INTEGER KORDER, NDATA, NKNOT
PARAMETER (KORDER=3, NDATA=5, NKNOT=NDATA+KORDER)
!
INTEGER I, NCOEF, NOUT
REAL BSCOEF(NDATA), BT0, BT1, DF, F, FDATA(NDATA),&
FLOAT, SQRT, X, XDATA(NDATA), XKNOT(NKNOT), XT
INTRINSIC FLOAT, SQRT
! Define function and derivative
F(X) = SQRT(X)
DF(X) = 0.5/SQRT(X)
! Set up interpolation points
DO 10 I=1, NDATA
XDATA(I) = FLOAT(I)/FLOAT(NDATA)
FDATA(I) = F(XDATA(I))
10 CONTINUE
! Generate knot sequence
CALL BSNAK (NDATA, XDATA, KORDER, XKNOT)
! Interpolate
CALL BSINT (NDATA, XDATA, FDATA, KORDER, XKNOT, BSCOEF)
! Get output unit number
CALL UMACH (2, NOUT)
! Write heading
WRITE (NOUT,99999)
! Print on a finer grid
NCOEF = NDATA
XT = XDATA(1)
! Evaluate spline
BT0 = BSDER(0,XT,KORDER,XKNOT,NCOEF,BSCOEF)
BT1 = BSDER(1,XT,KORDER,XKNOT,NCOEF,BSCOEF)
WRITE (NOUT,99998) XT, BT0, F(XT) - BT0, BT1, DF(XT) - BT1
DO 20 I=2, NDATA
XT = (XDATA(I-1)+XDATA(I))/2.0
! Evaluate spline
BT0 = BSDER(0,XT,KORDER,XKNOT,NCOEF,BSCOEF)
BT1 = BSDER(1,XT,KORDER,XKNOT,NCOEF,BSCOEF)
WRITE (NOUT,99998) XT, BT0, F(XT) - BT0, BT1, DF(XT) - BT1
XT = XDATA(I)
! Evaluate spline
BT0 = BSDER(0,XT,KORDER,XKNOT,NCOEF,BSCOEF)
BT1 = BSDER(1,XT,KORDER,XKNOT,NCOEF,BSCOEF)
WRITE (NOUT,99998) XT, BT0, F(XT) - BT0, BT1, DF(XT) - BT1
20 CONTINUE
99998 FORMAT (' ', F6.4, 5X, F7.4, 3X, F10.6, 5X, F8.4, 3X, F10.6)
 
 
99999 FORMAT (6X, 'X', 8X, 'S(X)', 7X, 'Error', 8X, 'S''(X)', 8X,&
'Error', /)
END
Output
 
X S(X) Error S’(X) Error
 
0.2000 0.4472 0.000000 1.0423 0.075738
0.3000 0.5456 0.002084 0.9262 -0.013339
0.4000 0.6325 0.000000 0.8101 -0.019553
0.5000 0.7077 -0.000557 0.6940 0.013071
0.6000 0.7746 0.000000 0.6446 0.000869
0.7000 0.8366 0.000071 0.5952 0.002394
0.8000 0.8944 0.000000 0.5615 -0.002525
0.9000 0.9489 -0.000214 0.5279 -0.000818
1.0000 1.0000 0.000000 0.4942 0.005814