Cubic Spline Interpolation Utility

This page contains a cubic spline interpolation utility. It is written in JavaScript, so make sure that JavaScript is enabled in your browser.
   
References:
Author:   David K. Kahaner,   National Bureau of Standards
From the book "Numerical Methods and Software" by
D. Kahaner, C. Moler, and S. Nash
Prentice Hall, 1988
   
Fritsch, F. N.;     and R.E. Carlson.
          "Monotone Piecewise Cubic Interpolation"
          SIAM J. Numer. Anal. 17, 2 (April 1980), 238 - 246
   
Fritsch, F. N.;     and J. Butland.
          "A Method for Constructing Local Monotone Piecewise Cubic Interpolants"
          Lawrence Livermore National Laboratory
          Preprint UCRL-87559 (April 1982)
   
De Boor, Carl.
          "A Practical Guide to Splines"
          Springer-Verlag, New York
          1978
   
Fritsch, F. N.
          "Piecewise Cubic Hermite Interpolation Package, Final Specifications"
          Lawrence Livermore National Laboratory
          Computer Documentation UCID-30194
          August 1982
   
The utility posted on this page is based on the sub-programs PCHEV and PCHEZ written by David K. Kahaner. These are top-level programs that control several sub-routines from the SLATEC collection. The original programs were written in FORTRAN and have been translated to Javascript here. Although all care has been taken to ensure that the sub-routines were translated accurately, some errors may have crept into the translation. These errors are mine; the original FORTRAN routines have been thoroughly tested and work properly. Please report any errors to the webmaster.


HOW TO USE THIS UTILITY
In the "Known Data" box below, enter the known (x, y) data pairs.
The data pairs should be entered one pair per line, with blanks between them--nothing else. No commas, periods, brackets, etc. (Also note that numbers in scientific notation are NOT recognized). For example, assume we have data that follows a   y   =   x*x   relationship. Data input to the box should look as follows:
0.5     0.25
1     1
2     4
3     9
4     16
5     25
Note that the data pairs must be entered in order of increasing x-value.
A maximum of fifty data pairs may be entered; if more than fifty data pairs are entered, any pairs after the fiftieth pair will be ignored.
   
In the "Points at which Interpolant Sought" section, enter the x-values at which the interpolating y-values are to be calculated. Once you click the "Interpolate" button, this utility will then calculate the values of y which are a cubic spline interpolation for the data at the specified x-points. Note that this utility accepts a maximum of ten x-points at which to calculate the corresponding y-value. If you need interpolating y-values at more than ten points, just repeatedly re-run the utility, entering the different x-points each time.
IMPORTANT:   Note the Error Code output.
Known Data
Enter the known data (up to fifty data pairs):
   
Points at which Interpolant Sought
Enter the x-values at which the interpolating y-values are to be calculated:
x1 y1
x2 y2
x3 y3
x4 y4
x5 y5
x6 y6
x7 y7
x8 y8
x9 y9
x10 y10
   
   
Error Code        
Error Code   = 0:   Normal Completion (No errors)
Error Code   > 0:   Extrapolation was performed at [Error Code] points
Return to Math Functions Page
Return to Thothworks Home Page