Cubic splines are preferred for many applications. Consider the spline composed of
cubic polynomials of the form
(1)
so that,
(2) and
(3) for![]()
The interpolating function must pass through all the data points, be continuous,
and have continuous derivative at the interior points. Furthermore, there are enough degrees
of freedom to impose continuous curvature as well (continuity of second derivative) at the interior points.
(4)
(5)
(6)
(7)
We have
unknowns and
equations (
from each of (1) and (2) and
from each of (3) and (4). Hence, we have the freedom to impose two extra conditions.
We can say
the width of the
interval, and![]()
Next, we shall write all the equations in terms of
(given) and C-k (unknown) only.
![]()
From equations (3) and (7)
![]()
From equations (1) and (4),![]()
From equations (1) and (5)![]()
![]()
So far we have obtained expressions for the coefficients
and
in terms of
and
All that remains is to match the slopes at the interior points.
From equations (2) and (6):
![]()
Substitute into this
(8) and
(9) to give![]()
After some simple algebra, we obtain a system of
equations to solve for![]()
![]()
The problem as been reduced from finding
coefficients
and
to finding
values of the curvature![]()
We only have
equations for
but we can obtain two additional equations by specifying
end conditions on the curvature, i.e. conditions involving
and![]()
-
Natural or free boundaries: take
i.e. the end splines have no curvature at the end points. -
Clamped boundaries: fix the slopes at each end to specified values.
-
Periodic boundaries: take

The last equations can be written in matrix form,![]()
In the case of natural splines (i.e. for
), the matrix is non-singular and has a tri-diagonal structure. The solution for
is unique and can easily be obtained using rapid tri-diagonal matrix solvers.


We can solve
for
and from this construct the splines![]()
Example: Find the natural spline for the following data:
|
|
1 |
2 |
3 |
4 |
|
|
0 |
1 |
3 |
4 |
|
|
2 |
4 |
3 |
4 |
From this![]()
MC=F becomes

Hence![]()
Thus, using equations (8), (9), and
we obtain
![]()
![]()
![]()
![]()
![]()