HOME

TheInfoList



OR:

In the
mathematical Mathematics is an area of knowledge that includes the topics of numbers, formulas and related structures, shapes and the spaces in which they are contained, and quantities and their changes. These topics are represented in modern mathematics ...
field of
numerical analysis Numerical analysis is the study of algorithms that use numerical approximation (as opposed to symbolic manipulations) for the problems of mathematical analysis (as distinguished from discrete mathematics). It is the study of numerical methods ...
, spline interpolation is a form of
interpolation In the 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 often has ...
where the interpolant is a special type of
piecewise In mathematics, a piecewise-defined function (also called a piecewise function, a hybrid function, or definition by cases) is a function defined by multiple sub-functions, where each sub-function applies to a different interval in the domain. P ...
polynomial In mathematics, a polynomial is an expression consisting of indeterminates (also called variables) and coefficients, that involves only the operations of addition, subtraction, multiplication, and positive-integer powers of variables. An exampl ...
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-ten 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 of 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 used in garments or stretchable fabrics. Elastic may also refer to: Alternative name * Rubber band, ring-shaped band of rubber used to hold objects togethe ...
ruler A ruler, sometimes called a rule, line gauge, or scale, is a device used in geometry and technical drawing, as well as the engineering and construction industries, to measure distances or draw straight lines. Variants Rulers have long ...
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 floating vessels. It normally takes place in a specialized facility known as a shipyard. Shipbuilders, also called shipwrights, follow a specialized occupation that traces its roots to bef ...
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 n + 1 knots, (x_0, y_0) through (x_n, y_n). There will be a cubic polynomial q_i(x)=y between each successive pair of knots (x_, y_) and (x_i, y_i) connecting to both of them, where i = 1, 2, \dots, n. So there will be n polynomials, with the first polynomial starting at (x_0, y_0), and the last polynomial ending at (x_n, y_n). The
curvature In mathematics, curvature is any of several strongly related concepts in geometry. Intuitively, the curvature is the amount by which a curve deviates from being a straight line, or a surface deviates from being a plane. For curves, the can ...
of any curve y = y(x) is defined as : \kappa = \frac, where y' and y'' are the first and second derivatives of y(x) with respect to x. To make the spline take a shape that minimizes the bending (under the constraint of passing through all knots), we will define both y' and y'' 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 : \begin q_i(x_i) = q_(x_i) = y_i \\ q'_i(x_i) = q'_(x_i) \\ q''_i(x_i) = q''_(x_i) \end \qquad 1 \le i \le n - 1. 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 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 ...
s. In addition to the three conditions above, a 'natural cubic spline' has the condition that q''_1(x_0) = q''_n(x_n) = 0. In addition to the three main conditions above, a 'clamped cubic spline' has the conditions that q'_1(x_0) = f'(x_0) and q'_n(x_n) = f'(x_n) where f'(x) is the derivative of the interpolated function. In addition to the three main conditions above, a 'not-a-knot spline' has the conditions that q_1(x_1) = q_2(x_1) and q_(x_) = q_(x_).


Algorithm to find the interpolating cubic spline

We wish to find each polynomial q_i(x) given the points (x_0, y_0) through (x_n, y_n). To do this, we will consider just a single piece of the curve, q(x), which will interpolate from (x_1, y_1) to (x_2, y_2). This piece will have slopes k_1 and k_2 at its endpoints. Or, more precisely, : q(x_1) = y_1, : q(x_2) = y_2, : q'(x_1) = k_1, : q'(x_2) = k_2. The full equation q(x) can be written in the symmetrical form where But what are k_1 and k_2? To derive these critical values, we must consider that : q' = \frac = \frac \frac = \frac \frac. 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 t = \tfrac 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 : q''_1(x_0) = 2 \frac = 0, : q''_n(x_n) = -2 \frac = 0, 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: : q_1(x_1) = q_2(x_1) \Rightarrow \frac k_0 + \left( \frac - \frac \right) k_1 - \frac k_2 = 2 \left( \frac - \frac \right), : q_(x_) = q_n(x_) \Rightarrow \frac k_ + \left( \frac - \frac \right) k_ - \frac k_n = 2\left( \frac- \frac \right), where \Delta x_i = x_i - x_,\ \Delta y_i = y_i - y_.


Example

In case of three points the values for k_0, k_1, k_2 are found by solving the tridiagonal linear equation system : \begin a_ & a_ & 0 \\ a_ & a_ & a_ \\ 0 & a_ & a_ \\ \end \begin k_0 \\ k_1 \\ k_2 \\ \end = \begin b_1 \\ b_2 \\ b_3 \\ \end with : a_ = \frac, : a_ = \frac, : a_ = \frac, : a_ = 2 \left(\frac + \frac\right), : a_ = \frac, : a_ = \frac, : a_ = \frac, : b_1 = 3 \frac, : b_2 = 3 \left(\frac + \frac\right), : b_3 = 3 \frac. For the three points : (-1,0.5),\ (0,0),\ (3,3), one gets that : k_0 = -0.6875,\ k_1 = -0.1250,\ k_2 = 1.5625, and from () and () that : a_1 = k_0(x_1 - x_0) - (y_1 - y_0) = -0.1875, : b_1 = -k_1(x_1 - x_0) + (y_1 - y_0) = -0.3750, : a_2 = k_1(x_2 - x_1) - (y_2 - y_1) = -3.3750, : b_2 = -k_2(x_2 - x_1) + (y_2 - y_1) = -1.6875. In the figure, the spline function consisting of the two cubic polynomials q_1(x) and q_2(x) given by () is displayed.


See also

* Cubic Hermite spline * 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 *
NURBS 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 is interpolation on functions of more than one variable; when the variates are spatial coordinates, it is also known as spatial interpolation. The function to be interpolated is known at given poi ...
*
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 of the dataset. Given a set of data points (x_0,y_0), \ldots, (x_n,y_n), with no ...
*
Smoothing spline Smoothing splines are function estimates, \hat f(x), obtained from a set of noisy observations y_i of the target f(x_i), in order to balance a measure of goodness of fit of \hat f(x_i) to y_i with a derivative based measure of the smoothness of ...
* Spline wavelet *
Thin plate spline Thin plate splines (TPS) are a spline-based technique for data interpolation and smoothing. They were introduced to geometric design by Duchon. They are an important special case of a polyharmonic spline. Robust Point Matching (RPM) is a common e ...
*
Polyharmonic spline In applied mathematics, polyharmonic splines are used for function approximation and data interpolation. They are very useful for interpolating and fitting scattered data in many dimensions. Special cases include thin plate splines and natural cu ...


Computer code

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


References

* *


External links


Cubic Spline Interpolation Online Calculation and Visualization Tool (with JavaScript source code)
*
Dynamic cubic splines with JSXGraph

Lectures on the theory and practice of spline interpolation

Paper which explains step by step how cubic spline interpolation is done, but only for equidistant knots.



A note on cubic splines

Information about spline interpolation (including code in Fortran 77)
{{authority control Splines (mathematics) Interpolation