In the
mathematical
Mathematics is a field of study that discovers and organizes methods, Mathematical theory, theories and theorems that are developed and Mathematical proof, proved for the needs of empirical sciences and mathematics itself. There are many ar ...
field of
numerical analysis
Numerical analysis is the study of algorithms that use numerical approximation (as opposed to symbolic computation, symbolic manipulations) for the problems of mathematical analysis (as distinguished from discrete mathematics). It is the study of ...
, spline interpolation is a form of
interpolation
In the mathematics, mathematical field of numerical analysis, interpolation is a type of estimation, a method of constructing (finding) new data points based on the range of a discrete set of known data points.
In engineering and science, one ...
where the interpolant is a special type of
piecewise
In mathematics, a piecewise function (also called a piecewise-defined function, a hybrid function, or a function defined by cases) is a function whose domain is partitioned into several intervals ("subdomains") on which the function may be ...
polynomial
In mathematics, a polynomial is a Expression (mathematics), mathematical expression consisting of indeterminate (variable), indeterminates (also called variable (mathematics), variables) and coefficients, that involves only the operations of addit ...
called a
spline. That is, instead of fitting a single, high-degree polynomial to all of the values at once, spline interpolation fits low-degree polynomials to small subsets of the values, for example, fitting nine cubic polynomials between each of the pairs of ten points, instead of fitting a single degree-nine polynomial to all of them. Spline interpolation is often preferred over
polynomial interpolation
In numerical analysis, polynomial interpolation is the interpolation of a given data set by the polynomial of lowest possible degree that passes through the points in the dataset.
Given a set of data points (x_0,y_0), \ldots, (x_n,y_n), with no ...
because the
interpolation error can be made small even when using low-degree polynomials for the spline. Spline interpolation also avoids the problem of
Runge's phenomenon
In the mathematical field of numerical analysis, Runge's phenomenon () is a problem of oscillation at the edges of an interval that occurs when using polynomial interpolation with polynomials of high degree over a set of equispaced interpolation ...
, in which oscillation can occur between points when interpolating using high-degree polynomials.
Introduction
Originally, ''
spline'' was a term for
elastic
Elastic is a word often used to describe or identify certain types of elastomer, Elastic (notion), elastic used in garments or stretch fabric, stretchable fabrics.
Elastic may also refer to:
Alternative name
* Rubber band, ring-shaped band of rub ...
ruler
A ruler, sometimes called a rule, scale, line gauge, or metre/meter stick, is an instrument used to make length measurements, whereby a length is read from a series of markings called "rules" along an edge of the device. Usually, the instr ...
s that were bent to pass through a number of predefined points, or ''knots''. These were used to make
technical drawing
Technical drawing, drafting or drawing, is the act and discipline of composing drawings that visually communicate how something functions or is constructed.
Technical drawing is essential for communicating ideas in industry and engineering. ...
s for
shipbuilding
Shipbuilding is the construction of ships and other Watercraft, floating vessels. In modern times, it normally takes place in a specialized facility known as a shipyard. Shipbuilders, also called shipwrights, follow a specialized occupation th ...
and construction by hand, as illustrated in the figure.
We wish to model similar kinds of curves using a set of mathematical equations. Assume we have a sequence of
knots,
through
. There will be a cubic polynomial
between each successive pair of knots
and
connecting to both of them, where
. So there will be
polynomials, with the first polynomial starting at
, and the last polynomial ending at
.
The
curvature
In mathematics, curvature is any of several strongly related concepts in geometry that intuitively measure the amount by which a curve deviates from being a straight line or by which a surface deviates from being a plane. If a curve or su ...
of any curve
is defined as
:
where
and
are the first and second derivatives of
with respect to
.
To make the spline take a shape that minimizes the bending (under the constraint of passing through all knots), we will define both
and
to be continuous everywhere, including at the knots. Each successive polynomial must have equal values (which are equal to the y-value of the corresponding datapoint), derivatives, and second derivatives at their joining knots, which is to say that
:
This can only be achieved if polynomials of degree 3 (cubic polynomials) or higher are used. The classical approach is to use polynomials of exactly degree 3 —
cubic splines.
In addition to the three conditions above, a ''natural cubic spline'' has the condition that
.
In addition to the three main conditions above, a ''clamped cubic spline'' has the conditions that
and
where
is the derivative of the interpolated function.
In addition to the three main conditions above, a ''not-a-knot spline'' has the conditions that
and
.
Algorithm to find the interpolating cubic spline
We wish to find each polynomial
given the points
through
. To do this, we will consider just a single piece of the curve,
, which will interpolate from
to
. This piece will have slopes
and
at its endpoints. Or, more precisely,
:
:
:
:
The full equation
can be written in the symmetrical form
where
But what are
and
? To derive these critical values, we must consider that
:
It then follows that
Setting and respectively in equations () and (), one gets from () that indeed first derivatives and , and also second derivatives
If now are points, and
where ''i'' = 1, 2, ..., ''n'', and
are ''n'' third-degree polynomials interpolating in the interval for ''i'' = 1, ..., ''n'' such that for ''i'' = 1, ..., ''n'' − 1, then the ''n'' polynomials together define a differentiable function in the interval , and
for ''i'' = 1, ..., ''n'', where
If the sequence is such that, in addition, holds for ''i'' = 1, ..., ''n'' − 1, then the resulting function will even have a continuous second derivative.
From (), (), () and () follows that this is the case if and only if
for ''i'' = 1, ..., ''n'' − 1. The relations () are linear equations for the values .
For the elastic rulers being the model for the spline interpolation, one has that to the left of the left-most "knot" and to the right of the right-most "knot" the ruler can move freely and will therefore take the form of a straight line with . As should be a continuous function of , "natural splines" in addition to the linear equations () should have
:
:
i.e. that
Eventually, () together with () and () constitute linear equations that uniquely define the parameters .
There exist other end conditions, "clamped spline", which specifies the slope at the ends of the spline, and the popular "not-a-knot spline", which requires that the third derivative is also continuous at the and points.
For the "not-a-knot" spline, the additional equations will read:
:
:
where
.
Example
In case of three points the values for
are found by solving the
tridiagonal linear equation system
:
with
:
:
:
:
:
:
:
:
:
:
For the three points
:
one gets that
:
and from () and () that
:
:
:
:
In the figure, the spline function consisting of the two cubic polynomials
and
given by () is displayed.
See also
*
Akima spline
*
Circular interpolation
*
Cubic Hermite spline
In numerical analysis, a cubic Hermite spline or cubic Hermite interpolator is a spline where each piece is a third-degree polynomial specified in Hermite form, that is, by its values and first derivatives at the end points of the correspondin ...
*
Centripetal Catmull–Rom spline
*
Discrete spline interpolation In the mathematical field of numerical analysis, discrete spline interpolation is a form of interpolation where the interpolant is a special type of piecewise polynomial called a discrete spline. A discrete spline is a piecewise polynomial such tha ...
*
Monotone cubic interpolation
*
Non-uniform rational B-spline
Non-uniform rational basis spline (NURBS) is a mathematical model using B-spline, basis splines (B-splines) that is commonly used in computer graphics for representing curves and Surface (mathematics), surfaces. It offers great flexibility and pr ...
*
Multivariate interpolation
In numerical analysis, multivariate interpolation or multidimensional interpolation is interpolation on ''multivariate functions'', having more than one variable or defined over a multi-dimensional domain. A common special case is bivariate inter ...
*
Polynomial interpolation
In numerical analysis, polynomial interpolation is the interpolation of a given data set by the polynomial of lowest possible degree that passes through the points in the dataset.
Given a set of data points (x_0,y_0), \ldots, (x_n,y_n), with no ...
*
Smoothing spline
*
Spline wavelet
*
Thin plate spline
*
Polyharmonic spline
References
Further reading
*
*
External links
Cubic Spline Interpolation Online Calculation and Visualization Tool (with JavaScript source code)*
Dynamic cubic splines with JSXGraphLectures on the theory and practice of spline interpolationPaper which explains step by step how cubic spline interpolation is done, but only for equidistant knots.A note on cubic splinesInformation about spline interpolation (including code in Fortran 77)TinySpline:Open source C-library for splines which implements cubic spline interpolation*
ttps://github.com/ValexCorp/Cubic-Interpolation Cubic Interpolation:Open source C#-library for cubic spline interpolation
{{authority control
Splines (mathematics)
Interpolation