5 Polynomial approximations - splines
We complete this Section by briefly describing another approach that can be used in the case where the data are exact.
Why are splines needed?
Fitting a polynomial to the data (using Lagrange polynomials, for example) works very well when there are a small number of data points. But if there were 100 data points it would be silly to try to fit a polynomial of degree 99 through all of them. It would be a great deal of work and anyway polynomials of high degree can be very oscillatory giving poor approximations between the data points to the underlying function.
What are splines?
Instead of using a polynomial valid for all , we use one polynomial for , then a different polynomial for then a different one again for , and so on.
We have already seen one instance of this approach in this Section. The “dot to dot" interpolation that we abandoned earlier (Figure 1(a)) is an example of a linear spline . There is a different straight line between each pair of data points.
The most commonly used splines are cubic splines . We use a different polynomial of degree three between each pair of data points. Let denote a cubic spline, then
And we need to find , , , , , …to determine the full form for the spline . Given the large number of quantities that have to be assigned (four for every pair of adjacent data points) it is possible to give some very nice properties:
- , , , …. This is the least we should expect, as it simply states that interpolates the given data.
- is continuous at the data points. This means that there are no “corners" at the data points - the whole curve is smooth.
- is continuous. This reduces the occurrence of points of inflection appearing at the data points and leads to a smooth interpolant.
Even with all of these requirements there are still two more properties we can assign to . A natural cubic spline is one for which is zero at the two end points. The natural cubic spline is, in some sense, the smoothest possible spline, for it minimises a measure of the curvature.
How is a spline found?
Now that we have described what a natural cubic spline is, we briefly describe how it is found. Suppose that there are data points. For a natural cubic spline we require and values of taken at the other data points are found from the system of equations in Key Point 4.
Admittedly the system of equations in Key Point 4 looks unappealing, but this is a “nice" system of equations. It was pointed out at the end of HELM booklet 30 that some applications lead to systems of equations involving matrices which are strictly diagonally dominant . The matrix above is of that type since the diagonal entry is always twice as big as the sum of off-diagonal entries.
Once the system of equations is solved for the second derivatives , the spline can be found as follows:
We now present an Example illustrating this approach.
Example 9
Find the natural cubic spline which interpolates the data
Solution
In the notation now established we have , and . For a natural cubic spline we require to be zero at and . Values of at the other data points are found from the system of equations given in Key Point 4. In this case the matrix is just and the pair of equations are:
In this case the equations become
Solving the coupled pair of equations leads to
We now find the coefficients , , etc. from the formulae and deduce that the spline is given by
Figure 5 shows how the spline interpolates the data.
Figure 5
Task!
Find the natural cubic spline which interpolates the data
In the notation now established we have , and . For a natural cubic spline we require to be zero at and . Values of at the other data points are found from the system of equations
In this case the equations become
Solving the coupled pair of equations leads to
We now find the coefficients , , etc. from the formulae and deduce that the spline is
Exercises
-
A political analyst is preparing a dossier involving the following data
She interpolates the data with a polynomial of degree 3 in order to find an approximation to . What value does she find for ?
-
Estimate
to an appropriate accuracy from the table of values below by means of an appropriate
quadratic interpolating polynomial.
1 3 3.5 6 99.8 295.5 342.9 564.6 -
An experiment is carried out and the data obtained as follows
Obtain the least squares best fit straight line, , to these data. (Give and to 2 decimal places.)
-
Find the natural cubic spline which interpolates the data
-
We are interested in the Lagrange polynomials at the point
so we consider
Similar calculations for the other Lagrange polynomials give
and we find that our interpolated polynomial, evaluated at is
which serves as the approximation to .
-
Estimate is (to sig. fig.)
-
We tabulate the data for convenience:
The quantity counts the number of data points and in this case is equal to 4.
It follows that the pair of equations for and are as follows:Solving these gives and , to 2 decimal places, and we see that the least squares best fit straight line to the given data is
-
In the notation now established we have
,
and
. For a
natural
cubic
spline we require
to be zero at
and
.
Values of
at the other data points are found from the system of equations
In this case the equations become
Solving the coupled pair of equations leads to
We now find the coefficients , , etc. from the formulae and deduce that the spline is given by