spline, a MATLAB code which sets up and evaluates splines.

These spline functions are typically used to

The most common use of this software is for situations where a set of (X,Y) data points is known, and it is desired to determine a smooth function which passes exactly through those points, and which can be evaluated everywhere. Thus, it is possible to get a formula that allows you to "connect the dots".

Of course, you could could just connect the dots with straight lines, but that would look ugly, and if there really is some function that explains your data, you'd expect it to curve around rather than make sudden angular turns. The functions in SPLINE offer a variety of choices for slinky curves that will make pleasing interpolants of your data.

There are a variety of types of approximation curves available, including:

Also included are a set of routines that return the local "basis matrix", which allows the evaluation of the spline in terms of local function data.


The computer code and data files described and made available on this web page are distributed under the MIT license


spline is available in a C version and a C++ version and a FORTRAN90 version and a MATLAB version.

Related Data and Programs:

bernstein_polynomial, a MATLAB code which evaluates the Bernstein polynomials, useful for uniform approximation of functions;

chebyshev, a MATLAB code which computes the Chebyshev interpolant/approximant to a given function over an interval.

divdif, a MATLAB code which uses divided differences to interpolate data.

hermite_interpolant, a MATLAB code which computes the Hermite interpolant, a polynomial that matches function values and derivatives.

hermite_cubic, a MATLAB code which can compute the value, derivatives or integral of a Hermite cubic polynomial, or manipulate an interpolating function made up of piecewise Hermite cubic polynomials.

interp, a MATLAB code which can be used for parameterizing and interpolating data;

lagrange_interp_1d, a MATLAB code which defines and evaluates the Lagrange polynomial p(x) which interpolates a set of data, so that p(x(i)) = y(i).


test_approx, a MATLAB code which defines a number of test problems for approximation and interpolation.

test_interp, a MATLAB code which defines a number of test problems for interpolation.

test_interp_1d, a MATLAB code which defines test problems for interpolation of data y(x), depending on a 1D argument.

vandermonde_approx_1d, a MATLAB code which finds a polynomial approximant to a function of 1D data by setting up and solving an overdetermined linear system for the polynomial coefficients, involving the Vandermonde matrix.

vandermonde_interp_1d, a MATLAB code which finds a polynomial interpolant to a function of 1D data by setting up and solving a linear system for the polynomial coefficients, involving the Vandermonde matrix.


  1. JA Brewer, DC Anderson,
    Visual Interaction with Overhauser Curves and Surfaces,
    SIGGRAPH 77,
    in Proceedings of the 4th Annual Conference on Computer Graphics and Interactive Techniques,
    ASME, July 1977, pages 132-137.
  2. Edwin Catmull, Raphael Rom,
    A Class of Local Interpolating Splines,
    in Computer Aided Geometric Design,
    edited by Robert Barnhill, Richard Reisenfeld,
    Academic Press, 1974,
    ISBN: 0120790505.
  3. Samuel Conte, Carl deBoor,
    Elementary Numerical Analysis,
    Second Edition,
    McGraw Hill, 1972,
    ISBN: 07-012446-4.
  4. Alan Davies, Philip Samuels,
    An Introduction to Computational Geometry for Curves and Surfaces,
    Clarendon Press, 1996,
    ISBN: 0-19-851478-6,
    LC: QA448.D38.
  5. Carl deBoor,
    A Practical Guide to Splines,
    Springer, 2001,
    ISBN: 0387953663.
  6. Jack Dongarra, Jim Bunch, Cleve Moler, Pete Stewart,
    LINPACK User's Guide,
    SIAM, 1979,
    ISBN13: 978-0-898711-72-1.
  7. Gisela Engeln-Muellges, Frank Uhlig,
    Numerical Algorithms with C,
    Springer, 1996,
    ISBN: 3-540-60530-4.
  8. James Foley, Andries vanDam, Steven Feiner, John Hughes,
    Computer Graphics, Principles and Practice,
    Second Edition,
    Addison Wesley, 1995,
    ISBN: 0201848406,
    LC: T385.C5735.
  9. Fred Fritsch, Judy Butland,
    A Method for Constructing Local Monotone Piecewise Cubic Interpolants,
    SIAM Journal on Scientific and Statistical Computing,
    Volume 5, Number 2, 1984, pages 300-304.
  10. Fred Fritsch, Ralph Carlson,
    Monotone Piecewise Cubic Interpolation,
    SIAM Journal on Numerical Analysis,
    Volume 17, Number 2, April 1980, pages 238-246.
  11. David Kahaner, Cleve Moler, Steven Nash,
    Numerical Methods and Software,
    Prentice Hall, 1989,
    ISBN: 0-13-627258-4,
    LC: TA345.K34.
  12. David Rogers, Alan Adams,
    Mathematical Elements of Computer Graphics,
    Second Edition,
    McGraw Hill, 1989,
    ISBN: 0070535299.

Source Code:

Last revised on 24 March 2019.