Next: E106 Binary Search Up: CERNLIB Previous: E104 Multidimensional Linear

## E105 Function Interpolation

Routine ID: E105
Author(s): F. JamesLibrary: KERNLIB
Submitter: G.A. ErskineSubmitted: 19.07.1973
Language: FortranRevised: 27.11.1984

Function subprogram DIVDIF interpolates in a table of arguments $a$j and function values $f$j= f(aj) , using an interpolating polynomial of specified degree which passes through tabular points which are symmetrically-positioned around the interpolation argument. The table arguments $a$j need not be equidistant.

Structure:

FUNCTION subprogram
User Entry Names: DIVDIF
Files Referenced: Printer
External References: KERMTR (N001), ABEND (Z035)

Usage:

In any arithmetic expression, DIVDIF(F,A,N,X,M)

has an approximate value of $f\left(X\right)$ .

F
( REAL) One-dimensional array. F(j) must be equal to the value at A(j) of the function to be interpolated, $\left(j=1,2,...,N\right)$ .
A
( REAL) One-dimensional array. A(j) must be equal to the table argument $a$j,(j=1,2,...,N) .
N
( INTEGER) Number of values in arrays F and A.
X
( REAL) Argument at which the interpolating polynomial is to be evaluated.
M
( INTEGER) Requested degree of the interpolating polynomial. If M exceeds $M$max=min(10,N-1) the interpolation is carried out using a polynomial of degree $M$max

instead of M. The original value of M is unchanged on exit.

Method:

Newton's divided difference formula is used. Except when X lies near one end of the table (in which case unsymmetrically-situated interpolation points are used), the interpolation procedure is as follows:
M odd:
An interpolating polynomial passing through $M+1$ successive points $\left(a$j,fj) symmetrically placed with respect to X is used.
M even:
The mean of two interpolating polynomials is used, each passing through $M+1$ successive points $\left(a$j,fj) , one polynomial having an extra point to the left of X, the other having an extra point to the right of X.
If X lies too close to either end of the table for symmetrically-positioned tabular values to be used, the $M+1$

values at the end of the table are used. If X lies outside the range of the table, the interpolation becomes an extrapolation, with corresponding loss of accuracy.

Restrictions:

The argument values $A\left(1\right),A\left(2\right),...$ must be in either strictly increasing order or strictly decreasing order. No error message is printed if this is not true.

Error handling:

Error E105.1: $N<2$ or $M<1$ . DIVDIF is set equal to zero and a message is printed unless subroutine KERSET (N001) has been called.

Notes:

$•$