QDVAL
This function evaluates a function defined on a set of points using quadratic interpolation.
Function Return Value
QDVAL — Value of the quadratic interpolant at X. (Output)
Required Arguments
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 3.
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: QDVAL (X, XDATA, FDATA [])
Specific: The specific interface names are S_QDVAL and D_QDVAL.
FORTRAN 77 Interface
Single: QDVAL (X, NDATA, XDATA, FDATA, CHECK)
Double: The double precision name is DQDVAL.
Description
The function QDVAL interpolates a table of values, using quadratic polynomials, returning an approximation to 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+1, fi+1). The number returned by QDVAL is q(x).
Comments
Informational error
Type
Code
Description
4
3
The XDATA values must be strictly increasing.
Example
In this example, the value of sin x is approximated at π/4 by using QDVAL on a table of 33 equally spaced values.
 
USE IMSL_LIBRARIES
 
IMPLICIT NONE
INTEGER NDATA
PARAMETER (NDATA=33)
!
INTEGER I, NOUT
REAL F, FDATA(NDATA), H, PI, QT, SIN, X,&
XDATA(NDATA)
INTRINSIC SIN
! Define function
F(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
! Evaluate at PI/4
QT = QDVAL(X,XDATA,FDATA)
! Get output unit number
CALL UMACH (2, NOUT)
! Print results
WRITE (NOUT,99999) X, F(X), QT, (F(X)-QT)
!
99999 FORMAT (15X, 'X', 6X, 'F(X)', 6X, 'QDVAL', 5X, 'ERROR', //, 6X,&
4F10.3, /)
END
Output
 
X F(X) QDVAL ERROR
 
0.785 0.707 0.707 0.000
Published date: 03/19/2020
Last modified date: 03/19/2020