CSDER

This function evaluates the derivative of a cubic spline.

Function Return Value

CSDER —  Value of the IDERIV-th derivative of the polynomial at X.   (Output)

Required Arguments

IDERIV — Order of the derivative to be evaluated.   (Input)
In particular, IDERIV = 0 returns the value of the polynomial.

X — Point at which the polynomial is to be evaluated.   (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:          CSDER (IDERIV, X, BREAK, CSCOEF, CSDER [,…])

Specific:         The specific interface names are S_CSDER and D_CSDER.

FORTRAN 77 Interface

Single:            CSDER (IDERIV, X, NINTV, BREAK, CSCOEF)

Double:          The double precision function name is DCSDER.

Description

The function CSDER evaluates the derivative of a cubic spline at a given point. It is a special case of the routine PPDER, which evaluates the derivative of a piecewise polynomial. (A cubic spline is a piecewise polynomial of order 4.) The routine PPDER is based on the routine PPVALU in de Boor (1978, page 89).

Example

In this example, we compute a cubic spline interpolant to a function f using IMSL routine CSINT. The values of the spline and its first and second derivatives are computed using CSDER. These values can then be compared with the corresponding values of the interpolated function.

 

      USE CSDER_INT

      USE CSINT_INT

      USE UMACH_INT

 

      IMPLICIT   NONE

      INTEGER    NDATA

      PARAMETER  (NDATA=10)

!

      INTEGER    I, NINTV, NOUT

      REAL       BREAK(NDATA), CDDF, CDF, CF, COS, CSCOEF(4,NDATA),&

                 DDF, DF, F, FDATA(NDATA), FLOAT, SIN, X,&

                 XDATA(NDATA)

      INTRINSIC  COS, FLOAT, SIN

!                                  Define function and derivatives

      F(X)   = SIN(15.0*X)

      DF(X)  = 15.0*COS(15.0*X)

      DDF(X) = -225.0*SIN(15.0*X)

!                                  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)

!                                  Get output unit number

      CALL UMACH (2, NOUT)

!                                  Write heading

      WRITE (NOUT,99999)

99999 FORMAT (9X, 'X', 8X, 'S(X)', 5X, 'Error', 6X, 'S''(X)', 5X,&

             'Error', 6X, 'S''''(X)', 4X, 'Error', /)

      NINTV = NDATA - 1

!                                  Print the interpolant on a finer grid

      DO 20  I=1, 2*NDATA

         X    = FLOAT(I-1)/FLOAT(2*NDATA-1)

         CF   = CSDER(0,X,BREAK,CSCOEF)

         CDF  = CSDER(1,X,BREAK,CSCOEF)

         CDDF = CSDER(2,X,BREAK,CSCOEF)

         WRITE (NOUT,'(F11.3, 3(F11.3, F11.6))') X, CF, F(X) - CF,&

                                               CDF, DF(X) - CDF,&

                                               CDDF, DDF(X) - CDDF

   20 CONTINUE

      END

Output

 

   X        S(X)     Error      S'(X)     Error      S''(X)    Error

0.000      0.000   0.000000     26.285 -11.284739   -379.458 379.457794
0.053      0.902  -0.192203      8.841   1.722460   -283.411 123.664734
0.105      1.019  -0.019333     -3.548   3.425718   -187.364 -37.628586
0.158      0.617   0.081009    -10.882   0.146207    -91.317 -65.824875
0.211     -0.037   0.021155    -13.160  -1.837700      4.730  -1.062027
0.263     -0.674  -0.046945    -10.033  -0.355268    117.916  44.391640
0.316     -0.985  -0.015060     -0.719   1.086203    235.999 -11.066727
0.368     -0.682  -0.004651     11.314  -0.409097    154.861  -0.365387
0.421      0.045  -0.011915     14.708   0.284042    -25.887  18.552732
0.474      0.708   0.024292      9.508   0.702690   -143.785 -21.041260
0.526      0.978   0.020854      0.161  -0.771948   -211.402 -13.411087
0.579      0.673   0.001410    -11.394   0.322443   -163.483  11.674103
0.632     -0.064   0.015118    -14.937  -0.045511     28.856 -17.856323
0.684     -0.724  -0.019246     -8.859  -1.170871    163.866   3.435547
0.737     -0.954  -0.044143      0.301   0.554493    184.217  40.417282
0.789     -0.675   0.012143     10.307   0.928152    166.021 -16.939514
0.842      0.027   0.038176     15.015  -0.047344     12.914 -27.575521
0.895      0.764  -0.010112     11.666  -1.819128   -140.193 -29.538193
0.947      1.114  -0.116304      0.258  -1.357680   -293.301  68.905701
1.000      0.650   0.000000    -19.208   7.812407   -446.408 300.092896


Visual Numerics, Inc.
Visual Numerics - Developers of IMSL and PV-WAVE
http://www.vni.com/
PHONE: 713.784.3131
FAX:713.781.9260