These subroutines compute the Newton divided difference coefficients and
perform a polynomial interpolation through a set of data points at specified
abscissas.
x, y, c, t, s | Subroutine |
Short-precision real | SPINT |
Long-precision real | DPINT |
Fortran | CALL SPINT | DPINT (x, y, n, c, ninit, t, s, m) |
C and C++ | spint | dpint (x, y, n, c, ninit, t, s, m); |
PL/I | CALL SPINT | DPINT (x, y, n, c, ninit, t, s, m); |
If ninit <= 0, all elements of c are undefined on entry.
If ninit > 0, c contains the Newton divided difference coefficients, cj for j = 1, ninit, for the interpolating polynomial through the data points (xj,yj) for j = 1, ninit. If ninit < n, the values of cj for j = ninit+1, n are undefined.
Specified as: a one-dimensional array of (at least) length n, containing numbers of the data type indicated in Table 155.
If ninit <= 0, this is the first call to this subroutine with the data in x and y; therefore, none of the Newton divided difference coefficients in c have been initialized.
If ninit > 0, a previous call to this subroutine was made with the data points (xj, yj) for j = 1, ninit, where:
Specified as: a fullword integer; ninit <= n.
Polynomial interpolation is performed at specified abscissas, ti for i = 1, m, in vector t, using the method of Newton divided differences through the data points:
where:
The interpolated value at each ti is returned in si for i = 1, m. See references [15] and [54]. The interpolating values returned in s are computed using the Newton divided difference coefficients, as defined in the following section.
The divided difference coefficients, cj for j = 1, n, are returned in vector c. These coefficients can then be reused on subsequent calls to this subroutine, using the same data points (xj, yj), but with new values of ti. If the number of data points is increased from one call this subroutine to the next, the new coefficients are computed, and the existing coefficients are updated (not recomputed). This feature can be used to test for the convergence of the interpolations through a sequence of an increasingly larger set of points.
The values specified for ninit and m indicate which combination of functions are performed by this subroutine: computing the coefficients, performing the interpolation, or both. If m = 0, only the divided difference coefficients are computed. No interpolation is performed. If n = 0, no computation or interpolation is performed.
For SPINT, the Newton divided differences and interpolating values are accumulated in long precision.
The Newton divided differences of the following data points:
are denoted by deltakyj for k = 0, 1, 2, ..., n-1 and j = 1, 2, ..., n-k, and are defined as follows:
The value s of the Newton divided difference form of the interpolating polynomial evaluated at an abscissa t is given by:
Therefore, on output, the coefficients in vector c are as follows:
Also, the interpolating values in s, in terms of c, are as follows for i = 1, m:
None
This example shows a quadratic polynomial interpolation on the initial call with the specified data points; that is, NINIT = 0, and C contains all undefined values. On output, NINIT and C are updated with new values.
X Y N C NINIT T S M | | | | | | | | CALL SPINT( X , Y , 3 , C , 0 , T , S , 2 )
X = (-0.50, 0.00, 1.00) Y = (0.25, 0.00, 1.00) C = ( . , . , . ) T = (-0.2, 0.2)
C = (1.00, 1.00, 1.00) NINIT = 3 S = (0.04, 0.04)
This example shows a quadratic polynomial interpolation on a subsequent call with the same data points specified in Example 1, but using a different set of abscissas in T. In this case, NINIT = N = 3, and C contains the values defined on output in Example 1. On output here, the values in NINIT and C are unchanged.
X Y N C NINIT T S M | | | | | | | | CALL SPINT( X , Y , 3 , C , 3 , T , S , 2 )
X = (-0.50, 0.00, 1.00) Y = (0.25, 0.00, 1.00) C = (1.00, 1.00, 1.00) T = (-0.10, 0.10)
C = (1.00, 1.00, 1.00) NINIT = 3 S = (0.01, 0.01)
This example is the same as Example 2 except that it specifies additional data points on the subsequent call to the subroutine. In this case, 0 < NINIT < N. On output here, the values in NINIT and C are updated. The interpolating polynomial is a degree of 4.
X Y N C NINIT T S M | | | | | | | | CALL SPINT( X , Y , 5 , C , 3 , T , S , 2 )
X = (-0.50, 0.00, 1.00, -1.00, 0.50) Y = (0.25, 0.00, 1.00, 1.10, 0.26) C = (1.00, 1.00, 1.00, . , . ) T = (-0.10, 0.10)
C = (0.04, -0.06, 1.02, -0.56, 0.26) NINIT = 5 S = (0.0072, 0.0130)