Cubic Spline Interpolation
Cubic spline interpolation is a special case for Spline interpolation that is used very often to avoid the problem of Runge's phenomenon. This method gives an interpolating polynomial that is smoother and has smaller error than some other interpolating polynomials such as Lagrange polynomial and Newton polynomial.
Definition
editGiven a set of n + 1 data points (x_{i},y_{i}) where no two x_{i} are the same and , the spline S(x) is a function satisfying:
 ;
 On each subinterval is a polynomial of degree 3, where
 for all
Let us assume that
where each is a cubic function, .
Boundary Conditions
editTo determine this cubic spline S(x), we need to determine for each i by:
 and , .
 , .
 , .
We can see that there are conditions, but we need to determine coefficients, so usually we add two boundary conditions to solve this problem.
There are three types of common boundary conditions:
 First derivatives at the endpoints are known:
 .
 Second derivatives at the endpoints are known:
 .
 When the exact function f(x) is a periodic function with period , S(x) is a periodic function with period too. Thus
 .
Methods
editThere are several methods that can be used to find the spline function S(x) according to its corresponding conditions. Since there are 4n coefficients to determine with 4n conditions, we can easily plug the values we know into the 4n conditions and then solve the system of equations. Note that all the equations are linear with respect to the coefficients, so this is workable and computers can do it quite well.
The algorithm given in Spline interpolation is also a method by solving the system of equations to obtain the cubic function in the symmetrical form.
The other method used quite often is Cubic Hermite spline, this gives us the spline in Hermite form.
Here, we discuss another method using second derivatives to find the expression for spline .
Let , , and . Note that 's are unknown (except for type II boundary condition, are given).
Since each is a cubic polynomial, is linear.
By Lagrange interpolation, we can interpolate each on since and , the Lagrange form of this interpolating polynomial is:
 for .
Integrating the above equation twice and using the condition that and to determine the constants of integration, we have

(
)
This expression gives us the cubic spline S(x) if can be determined.
For when , we can calculate that
Therefore,
Similarly, when , we can shift the index to obtain

(
)
Thus,
Since , we can derive

(
)
where

(
)
and is a divided difference.
According to different boundary conditions, we can solve the system of equations above to obtain the values of 's.
I. For type I boundary condition, we are given and . According to equation (2), we can obtain

.
(
)

Similarly, simplifying
we will have

.
(
)

Therefore, let and , combine (3), (5.1) and (5.2) together, so the system of equations that we need to solve is

(
)

II. For type II boundary condition, we are given

and
(
)

directly, so let , , and , and we need to solve the system of equations in the same form as (6).
Example
editFor points (0,0),(1,0.5), (2,2) and (3,1.5), find the interpolating cubic spline satisfying and .
Solution:
We can easily see that for so and
Also, since this is the type I boundary condition problem, we can calculate that
 and
Therefore, plug into the system of equations, we have
The solution is and
Therefore, by the general expression of the solution, we have
Similarly,
 and
Thus the cubic spline is
Exercise
edit
Therefore, we can construct the system of equations:
Solution:
Since and , we can find the solution:
 and .
Plug these into the general expression for cubic spline and simplify, we can obtain
You can see the difference of the two cubic splines in Figure 1.
References
editPolynomial and Spline Interpolation, http://www.ohiouniversityfaculty.com/youngt/IntNumMeth/lecture19.pdf
数值分析，李庆扬，王能超，易大易，2001. ISBN 7302045615 (Numerical Analysis, Qinyang Li, Nengchao Wang, Dayi yi.)