PCHIM(3)

SYNOPSIS
SUBROUTINE PCHIM (N, X, F, D, INCFD, IERR)

NAME
pchim - Set derivatives needed to determine a monotone piecewise cubic Hermite interpolant to given data. Boundary values are provided which are compatible with monotonicity. The interpolant will have an extremum at each point where mono- tonicity switches direction. (See PCHIC if user control is desired over boundary or switch conditions.)

LIBRARY
SLATEC (PCHIP)

CATEGORY
E1A

TYPE
SINGLE PRECISION (PCHIM-S, DPCHIM-D)

KEYWORDS
CUBIC HERMITE INTERPOLATION, MONOTONE INTERPOLATION, PCHIP, PIECEWISE CUBIC INTERPOLATION

AUTHOR
Fritsch, F. N., (LLNL) Lawrence Livermore National Laboratory P.O. Box 808 (L-316) Livermore, CA 94550 FTS 532-4275, (510) 422-4275

DESCRIPTION
PCHIM: Piecewise Cubic Hermite Interpolation to Monotone data. Sets derivatives needed to determine a monotone piecewise cubic Hermite interpolant to the data given in X and F. Default boundary conditions are provided which are compatible with monotonicity. (See PCHIC if user control of boundary con- ditions is desired.) If the data are only piecewise monotonic, the interpolant will have an extremum at each point where monotonicity switches direc- tion. (See PCHIC if user control is desired in such cases.) To facilitate two-dimensional applications, includes an increment between successive values of the F- and D-arrays. The resulting piecewise cubic Hermite function may be evaluated by PCHFE or PCHFD. ---------------------------------------------------------------------- Calling sequence: PARAMETER (INCFD = ...) INTEGER N, IERR REAL X(N), F(INCFD,N), D(INCFD,N) CALL PCHIM (N, X, F, D, INCFD, IERR) Parameters: N -- (input) number of data points. (Error return if N.LT.2 .) If N=2, simply does linear interpolation. X -- (input) real array of independent variable values. The elements of X must be strictly increasing: X(I-1) .LT. X(I), I = 2(1)N. (Error return if not.) F -- (input) real array of dependent variable values to be inter- polated. F(1+(I-1)*INCFD) is value corresponding to X(I). PCHIM is designed for monotonic data, but it will work for any F-array. It will force extrema at points where mono- tonicity switches direction. If some other treatment of switch points is desired, PCHIC should be used instead. ----- D -- (output) real array of derivative values at the data points. If the data are monotonic, these values will determine a a monotone cubic Hermite function. The value corresponding to X(I) is stored in D(1+(I-1)*INCFD), I=1(1)N. No other entries in D are changed. INCFD -- (input) increment between successive values in F and D. This argument is provided primarily for 2-D applications. (Error return if INCFD.LT.1 .) IERR -- (output) error flag. Normal return: IERR = 0 (no errors). Warning error: IERR.GT.0 means that IERR switches in the direction of monotonicity were detected. "Recoverable" errors: IERR = -1 if N.LT.2 . IERR = -2 if INCFD.LT.1 . IERR = -3 if the X-array is not strictly increasing. (The D-array has not been changed in any of these cases.) NOTE: The above errors are checked in the order listed, and following arguments have **NOT** been validated.

REFERENCES
1. F. N. Fritsch and J. Butland, A method for construc- ting local monotone piecewise cubic interpolants, SIAM Journal on Scientific and Statistical Computing 5, 2 (June 1984), pp. 300-304. 2. F. N. Fritsch and R. E. Carlson, Monotone piecewise cubic interpolation, SIAM Journal on Numerical Ana- lysis 17, 2 (April 1980), pp. 238-246.

ROUTINES CALLED
PCHST, XERMSG

REVISION HISTORY (YYMMDD)
811103 DATE WRITTEN
820201 1. Introduced PCHST to reduce possible over/under- flow problems. 2. Rearranged derivative formula for same reason.
820602 1. Modified end conditions to be continuous functions of data when monotonicity switches in next interval. 2. Modified formulas so end conditions are less prone of over/underflow problems.
820803 Minor cosmetic changes for release 1.
870813 Updated Reference 1.
890411 Added SAVE statements (Vers. 3.2).
890531 Changed all specific intrinsics to generic. (WRB)
890703 Corrected category record. (WRB)
890831 Modified array declarations. (WRB)
890831 REVISION DATE from Version 3.2
891214 Prologue converted to Version 4.0 format. (BAB)
900315 CALLs to XERROR changed to CALLs to XERMSG. (THJ)
920429 Revised format and order of references. (WRB,FNF)