It may happen that an interpolating polynomial shows relatively strong oscillations even in situations where the given points suggest a more or less steady curvature. Obviously, a polynomial is not a useful interpolation, then. Instead, one should seek to interpolate between two neighboring supporting points.
Using straight lines is too simple, since the interpolation function then has kinks, and it is not differentiable at the supporting points. The piecewise interpolation must be done in a way that the slope is continuous at the joints, i.e. the total interpolation function must be continuously differentiable.
In general, this means that four conditions apply to all piecewise interpolating functions: At the ends of each interval, both the interpolating function and its first derivative must attain certain values. Therefore, the most simple solution is to use cubic polynomials for the piecewise interpolation.
However, since the derivatives are not known, one can only make it a condition that adjoining interpolating functions have equal derivatives at the supporting points. This reduces the number of conditions available for the determination of the interpolating functions. Therefore, an additional condition is needed.
The curvature of a function is related to its first and second derivative. Then, making it an additional condition that adjoining interpolating functions also have equal second derivatives at the supporting points, the interpolation function will additionally have a continuous curvature, i.e. it will be twice continuously differentiable.
Finally, only the slope at the first and the last supporting point are a priori
unknown. Usually these are determined by the further condition that the second derivatives vanish, which implies
zero curvature at the ends.
Definition:
natural cubic spline
There are \(n+1\) given points
\((x_0,y_0),(x_1,y_1),\ldots,(x_n,y_n),n\geq 2\) with \(x_0\lt x_1\lt x_2\lt\ldots{}x_{n-1}\lt
x_n\). A function \(S(x)\) on \([x_0,x_n]\) is called natural cubic spline if:
In each interval \([x_{j-1},x_j]\), \(j\in\{1,2,3,\dots,n\}\), \(S(x)\) is given by a cubic polynomial \(p_j(x)\).
\(S(x)\) satisfies interpolation conditions: \(S(x_j)=y_j\) for all \(j\in\{0,1,2,\dots,n\}\) (i.e. \(p_j(x_{j-1})=y_{j-1}\), \(p_j(x_j)=y_j\) for all \(j\in\{1,2,3,\dots,n\}\)).
\(S(x)\) is twice continuously differentiable in \([x_0,x_n]\), i.e. for each \(j\in\{1,2,3,\dots,n-1\}\) it holds that \(p_j'(x_j)=p_{j+1}'(x_j)\) and \(p_j''(x_j)=p_{j+1}''(x_j)\).
At its ends, the curvature of \(S(x)\) vanishes: \(p_1''(x_0)=0\), \(p_n''(x_n)=0\).
Alternatively, also zero slope at the ends of \(S(x)\) can be used as condition #4; then, however, the resulting spline is not termed “natural” spline anymore.
Each polynomial of 3\(^{\text{rd}}\) degree, \(p_j(x)=a_j+b_j x+c_j x^2+d_j x^3\), has four unknown coefficients \(a_j, b_j, c_j, d_j\). For \(n\) cubic polynomials \(p_j(x)\), \(4n\) coefficients have to be determined. To that end, \(4n\) equations are needed. They are related to the above conditions as follows:
\(2n\) equations from #2;
\(n-1\) equations both for the 1\(^{\text{st}}\) and 2\(^{\text{nd}}\) derivative, i.e. \(2(n-1)\) equations from #3;
two more equations from #4.
All these equations can be written in form of a single matrix equation for the unknown coefficients, arranged as a vector, with the matrix containing mainly powers of the \(x_j\) (as well as many zeros) and the left-hand side of the equation containing the \(y_j\) (and also many zeros). This allows to treat the problem by determining the inverse matrix and solving for the vector of the coefficients. Below, both conditions #4 are shown together with two of #2 and two of #3 (one for the first and one for second derivative):
![]() |
![]() |
![]() |
![]() |
© J. Carstensen (Comp. Math.)