MATH/APPM 4650
Class notes, February 20

Cubic splines, and interpolation review

Recall that we never want to use a high-order interpolating polynomial for data that is not known to high accuracy.

If the data is experimental and has some error, we should use regression (Chapter 8).

Suppose the data does not have any error, but we do not know it to high accuracy.

Typical example:
We have several points on a graph; the points are correct and known to one decimal place. Draw a curve passing through them.

A high-order polynomial will tend to magnify very slight errors in these points. It will also tend to oscillate a lot between the values.

Instead, we use a low-order polynomial, but we use a different polynomial between each two points.

Example (from before):
We have five points, (-1,5), (1,6), (1.5, 4), (2,-2), and (4,-1).
We saw that the fourth-order interpolating polynomial looked pretty strange.

A fourth-order interpolating polynomial for five points.

Instead, the idea is to use piecewise-defined polynomials.

We could do piecewise-linear. If we do that, we can certainly connect the dots, but the graph will have lots of kinks.

Connecting the dots with a piecewise linear function.


To improve things, we could do piecewise-quadratic.

At first glance, you'd think there aren't enough parameters to get this to work.
How do we know what parabola to draw between each two points?

However, we can use the extra freedom to match up the derivatives.
First parabola from -1 to 1:
a0 x2 + b0 x + c0.
Two equations come from the fact that it must pass through (-1,5) and (1,6): Similarly we have for the second parabola from 1 to 1.5:
a1 x2 + b1 x + c1.
Two equations come from passing through (1,6) and (1.5,4). Finally we get an equation by matching up the derivatives at x=1.

2 a0 + b0 = 2 a1 + b1.



If we keep doing this, we will end up with four parabolas (thus twelve unknown coefficients).
Eight equations come from making them pass through the points.
Three equations come from matching the derivatives at the points.
One coefficient is unknown! So we actually have a whole family of parabolas.

Connecting the dots with a bunch of quadratic splines.

We could try to figure out an endpoint condition to determine the quadratic spline, but since nobody ever uses quadratic splines in real life, we'll just move on.


Observe that even though the quadratic spline curve looks smooth, it's really not.
Here are the graphs of the derivatives of the quadratic splines.

The derivative of the family of quadratic splines.

Imagine you're in a car, and the quadratic spline is the graph of your position. Obviously position is continuous, and its derivative (velocity) is also continuous. (Unless you crash into a wall.)
But the acceleration will not be continuous. This corresponds to the driver constantly slamming on the brakes or jamming down the gas pedal. Rather uncomfortable!


For a cubic spline, we use a third-order polynomial. This gives us four coefficients for each cubic, so 16 in all (if there are five points).
We have 8 equations which come from matching the points.
We get 3 more equations by matching the first derivative at each point.
Then we can get 3 equations by matching the second derivative at each point.
This gives 14 equations in all for 16 coefficients. Two coefficients are free.
The book suggests specifying them in various ways.
A natural cubic spline. A clamped cubic spline.
Derivatives at endpoints set to zero.


In practice, other methods are also used.


Commands: Each software package has several spline commands.



General review of interpolation: