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

edit

Given a set of n + 1 data points (xi,yi) where no two xi are the same and  , the spline S(x) is a function satisfying:

  1.  ;
  2. On each subinterval   is a polynomial of degree 3, where  
  3.   for all  


Let us assume that

 

where each   is a cubic function,  .

Boundary Conditions

edit

To 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:

  1. First derivatives at the endpoints are known:
     .
    This is called clamped boundary conditions.
  2. Second derivatives at the endpoints are known:
     .
    The special case   is called natural or simple boundary conditions.
  3. When the exact function f(x) is a periodic function with period  , S(x) is a periodic function with period   too. Thus
     .
    The spline functions S(x) satisfying this type of boundary condition are called periodic splines.

Methods

edit

There 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

 

 

 

 

 

(1)

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

 

 

 

 

 

(2)

Thus,  

Since  , we can derive

 

 

 

 

 

(3)

where

 

 

 

 

 

(4)

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

 
 
 .

 

 

 

 

(5.1)

Similarly, simplifying

 

we will have

 .

 

 

 

 

(5.2)

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

 

 

 

 

 

(6)

II. For type II boundary condition, we are given

  and  

 

 

 

 

(7)

directly, so let  ,  , and  , and we need to solve the system of equations in the same form as (6).

Example

edit

For points (0,0),(1,0.5), (2,2) and (3,1.5), find the interpolating cubic spline   satisfying   and  .

Exercise

edit

For points (0,0), (1,0.5), (2,2) and (3,1.5), find the interpolating cubic spline   satisfying   and  .
Since this is the type II boundary condition, we use
 

and  

.
Also, we have
 

,  

,  

and  

.
Same as the above example, we have
 

and
 

and  

.


Therefore, we can construct the system of equations:

You can see the difference of the two cubic splines in Figure 1.

 
Figure 1: Interpolating Cubic Splines

References

edit

Polynomial and Spline Interpolation, http://www.ohiouniversityfaculty.com/youngt/IntNumMeth/lecture19.pdf

数值分析,李庆扬,王能超,易大易,2001. ISBN 7-302-04561-5 (Numerical Analysis, Qinyang Li, Nengchao Wang, Dayi yi.)