Spline interpolation

1

In the mathematical field of numerical analysis, spline interpolation is a form of interpolation where the interpolant is a special type of piecewise polynomial 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 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 which oscillation can occur between points when interpolating using high-degree polynomials.

Introduction

Originally, spline was a term for elastic rulers that were bent to pass through a number of predefined points, or knots. These were used to make technical drawings for shipbuilding 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 and (x_i, y_i) connecting to both of them, where. 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 of any curve y = y(x) is defined as 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 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 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 and.

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, 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 It then follows that Setting and respectively in equations and, one gets from that indeed first derivatives q′(x1) = k1 and q′(x2) = k2 , and also second derivatives If now (xi, yi), i = 0, 1, ..., n are n + 1 points, and where i = 1, 2, ..., n, and are n third-degree polynomials interpolating y in the interval xi−1 ≤ x ≤ xi for i = 1, ..., n such that q′i (xi) = q′i+1(xi) for i = 1, ..., n − 1, then the n polynomials together define a differentiable function in the interval x0 ≤ x ≤ xn , and for i = 1, ..., n, where If the sequence k0, k1, ..., kn is such that, in addition, q′′i(xi) = q′′i+1(xi) 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 n − 1 linear equations for the n + 1 values k0, 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 with q′′ = 0 . As q′′ should be a continuous function of x, "natural splines" in addition to the n − 1 linear equations should have i.e. that Eventually, together with and constitute n + 1 linear equations that uniquely define the n + 1 parameters k0, 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 the third derivative is also continuous at the x1 and xn−1 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 q_1(x) and q_2(x) given by is displayed.

This article is derived from Wikipedia and licensed under CC BY-SA 4.0. View the original article.

Wikipedia® is a registered trademark of the Wikimedia Foundation, Inc.
Bliptext is not affiliated with or endorsed by Wikipedia or the Wikimedia Foundation.

Edit article