QDDER
This function evaluates the derivative of a function defined on a set of points using quadratic interpolation.
Function Return Value
QDDER — Value of the IDERIV-th derivative of the quadratic interpolant at X. (Output)
Required Arguments
IDERIV — Order of the derivative. (Input)
X — Coordinate of the point at which the function is to be evaluated. (Input)
XDATA — Array of length NDATA containing the location of the data points. (Input) XDATA must be strictly increasing.
FDATA — Array of length NDATA containing the function values. (Input)
FDATA(I) is the value of the function at XDATA(I).
Optional Arguments
NDATA — Number of data points. (Input)
NDATA must be at least three.
Default: NDATA = size (XDATA,1).
CHECK — Logical variable that is .TRUE. if checking of XDATA is required or .FALSE. if checking is not required. (Input)
Default: CHECK = .TRUE.
FORTRAN 90 Interface
Generic: QDDER(IDERIV, X, XDATA, FDATA [])
Specific: The specific interface names are S_QDDER and D_QDDER.
FORTRAN 77 Interface
Single: QDDER(IDERIV, X, NDATA, XDATA, FDATA, CHECK)
Double: The double precision function name is DQDDER.
Description
The function QDDER interpolates a table of values, using quadratic polynomials, returning an approximation to the derivative of the tabulated function. Let (xifi) for i = 1, n be the tabular data. Given a number x at which an interpolated value is desired, we first find the nearest interior grid point xi. A quadratic interpolant q is then formed using the three points (xi-1, fi-1)(xi, fi), and (xi+1fi+1). The number returned by QDDER is q(j)(x), where j = IDERIV.
1. Informational error
Type
Code
Description
4
3
The XDATA values must be strictly increasing.
2. Because quadratic interpolation is used, if the order of the derivative is greater than two, then the returned value is zero.
Example
In this example, the value of sin x and its derivatives are approximated at π/4 by using QDDER on a table of 33 equally spaced values.

USE IMSL_LIBRARIES

IMPLICIT NONE
INTEGER NDATA
PARAMETER (NDATA=33)
!
INTEGER I, IDERIV, NOUT
REAL COS, F, F1, F2, FDATA(NDATA), H, PI,&
QT, SIN, X, XDATA(NDATA)
LOGICAL CHECK
INTRINSIC COS, SIN
! Define function and derivatives
F(X) = SIN(X)
F1(X) = COS(X)
F2(X) = -SIN(X)
! Generate data points
XDATA(1) = 0.0
FDATA(1) = F(XDATA(1))
H = 1.0/32.0
DO 10 I=2, NDATA
XDATA(I) = XDATA(I-1) + H
FDATA(I) = F(XDATA(I))
10 CONTINUE
! Get value of PI and set X
PI = CONST('PI')
X = PI/4.0
! Check XDATA
CHECK = .TRUE.
! Get output unit number
CALL UMACH (2, NOUT)
WRITE (NOUT,99998)
IDERIV = 0
QT = QDDER(IDERIV,X,XDATA,FDATA, CHECK=CHECK)
WRITE (NOUT,99999) X, IDERIV, F(X), QT, (F(X)-QT)
CHECK = .FALSE.
! Evaluate first derivative at PI/4
IDERIV = 1
QT = QDDER(IDERIV,X,XDATA,FDATA)
WRITE (NOUT,99999) X, IDERIV, F1(X), QT, (F1(X)-QT)
! Evaluate second derivative at PI/4
IDERIV = 2
QT = QDDER(IDERIV,X,XDATA,FDATA, CHECK=CHECK)
WRITE (NOUT,99999) X, IDERIV, F2(X), QT, (F2(X)-QT)
!
99998 FORMAT (33X, 'IDER', /, 15X, 'X', 6X, 'IDER', 6X, 'F (X)',&
5X, 'QDDER', 6X, 'ERROR', //)
99999 FORMAT (7X, F10.3, I8, 3F12.3/)
END
Output

IDER
X IDER F (X) QDDER ERROR

0.785 0 0.707 0.707 0.000

0.785 1 0.707 0.707 0.000

0.785 2 -0.707 -0.704 -0.003