This article includes a list ofgeneral references, butit lacks sufficient correspondinginline citations. Please help toimprove this article byintroducing more precise citations.(July 2021) (Learn how and when to remove this message) |
In themathematical field ofnumerical analysis,spline interpolation is a form ofinterpolation where the interpolant is a special type ofpiecewisepolynomial called aspline. 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,[clarification needed] instead of fitting a single degree-nine polynomial to all of them. Spline interpolation is often preferred overpolynomial interpolation because theinterpolation error can be made small even when using low-degree polynomials for the spline.[1] Spline interpolation also avoids the problem ofRunge's phenomenon, in which oscillation can occur between points when interpolating using high-degree polynomials.

Originally,spline was a term for elastic rulers that were bent to pass through a number of predefined points, orknots. These were used to maketechnical drawings forshipbuilding 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.
Thecurvature 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, anatural cubic spline has the condition that.
In addition to the three main conditions above, aclamped cubic spline has the conditions that and where is the derivative of the interpolated function.
In addition to the three main conditions above, anot-a-knot spline has the conditions that and.[2]
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
| 1 |
where
| 2 |
| 3 |
| 4 |
But what are and? To derive these critical values, we must consider that
It then follows that
| 5 |
| 6 |
Settingt =0 andt =1 respectively in equations (5) and (6), one gets from (2) that indeed first derivativesq′(x1) =k1 andq′(x2) =k2, and also second derivatives
| 7 |
| 8 |
If now(xi,yi),i = 0, 1, ...,n aren + 1 points, and
| 9 |
wherei = 1, 2, ...,n, and aren third-degree polynomials interpolatingy in the intervalxi−1 ≤x ≤xi fori = 1, ...,n such thatq′i (xi) =q′i+1(xi) fori = 1, ...,n − 1, then then polynomials together define adifferentiable function in the intervalx0 ≤x ≤xn, and
| 10 |
| 11 |
fori = 1, ...,n, where
| 12 |
| 13 |
| 14 |
If the sequencek0,k1, ...,kn is such that, in addition,q′′i(xi) =q′′i+1(xi) holds fori = 1, ...,n − 1, then the resulting function will even have a continuous second derivative.
From (7), (8), (10) and (11) follows that this is the case if and only if
| 15 |
fori = 1, ...,n − 1. The relations (15) aren − 1 linear equations for then + 1 valuesk0,k1, ...,kn.
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 withq′′ = 0. Asq′′ should be acontinuous function ofx, "natural splines" in addition to then − 1 linear equations (15) should have
i.e. that
| 16 |
| 17 |
Eventually, (15) together with (16) and (17) constituten + 1 linear equations that uniquely define then + 1 parametersk0,k1, ...,kn.
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 thethird derivative is also continuous at thex1 andxn−1 points.For the "not-a-knot" spline, the additional equations will read:
where.

In case of three points the values for are found by solving thetridiagonal linear equation system
with
For the three points
one gets that
In the figure, the spline function consisting of the two cubic polynomials and given by (9) is displayed.