You are on page 1of 4

MATH317 FIFTH & SIXTH TUTORIAL

JAN FEYS

1. C UBIC S PLINE I NTERPOLATION


Given a function f defined on [a, b] and a set of nodes1
a = x0 < x1 < . . . < xn1 < xn = b,
a cubic spline interpolant S for f is a function

S0 (x)
if x [x0 , x1 )

S1 (x)
if x [x1 , x2 )
S(x) =
.

..

Sn1 (x) if x [xn1 , xn ]


where the Sj (x) are cubic polynomials of the form
Sj (x) = aj + bj (x xj ) + cj (x xj )2 + dj (x xj )3
satisfying the following conditions.

(n interpolation conditions) For S to interpolate we need Sj (xj ) = f (xj ) for j =


0, 1, . . . , n 1.
(n continuity conditions) For the pieces to link in a continuous way it is necessary
that Sj (xj+1 ) = f (xj+1 ) for j = 0, 1, . . . , n 1.
((2n 2) smoothness conditions) The pieces should link in a smooth way. The
0
00
associated conditions are Sj+1
(xj+1 ) = Sj0 (xj ) and Sj+1
(xj+1 ) = Sj00 (xj+1 ) for

j = 0, 1, . . . , n 2.
(2 extra conditions) There are multiple choices here for the two extra conditions.
Two frequently used sets of conditions are the free or natural boundary conditions
S 00 (x0 ) = S 00 (xn ) = 0
or the clamped boundary conditions
S 0 (x0 ) = f 0 (x0 ),

S 0 (xn ) = f 0 (xn ).

1The word node is used as a synonym for interpolation point.

The unknowns are the aj , bj , cj , dj with j = 0, 1, . . . , n 1. They can be determined from


the conditions above by solving a matrix equation. Note that the aj can be easily found to
satisfy aj = f (xj ). Furthermore, the matrix system will be only for the cj . The bj and dj
can be found from these.
1.1. Uniqueness Theorem. There exists a unique natural spline for any set of points
a = x0 < x1 < . . . < xn1 < xn = b.
If f 0 (a) and f 0 (b) are given, then there exists a unique clamped spline as well.
The proof is rather easy. A cubic spline problem with n + 1 points has 4n unknowns.
The set of conditions given above contains 4n equations. There is thus an equal amount
of equations and unknowns which means that in general the unknowns will be uniquely
determined. The boundary conditions are crucial to the uniqueness of the spline. Which
set of boundary conditions we choose depends on the problem.
2. A N E XERCISE ON C UBIC S PLINE I NTERPOLATION
Determine the free cubic spline S that interpolates the data f (0) = 0, f (1) = 1, f (2) = 2.
Three points x0 = 0, x1 = 1 and x2 = 2 are given so n = 2. There will be two pieces S0
and S1 to the spline. The goal is to determine a0 , b0 , c0 , d0 , a1 , b1 , c1 , d1 . This is done by
imposing the eight conditions from higher. Remember that
S0 (x) = a0 + b0 (x x0 ) + c0 (x x0 )2 + d0 (x x0 )3
and
S1 (x) = a1 + b1 (x x1 ) + c1 (x x1 )2 + d1 (x x1 )3 .
Let us go over the conditions in the same order as we did earlier.

Two interpolation conditions: S0 (x0 ) = f (x0 ) and S1 (x1 ) = f (x1 ). We get back
a0 = f (x0 ) = 0 and a1 = f (x1 ) = 1,
two continuity conditions: S0 (x1 ) = f (x1 ) and S1 (x2 ) = f (x2 ). Thus
1 = S0 (x1 ) = a0 + b0 (x1 x0 ) + c0 (x1 x0 )2 + d0 (x1 x0 )3 = b0 + c0 + d0
and
2 = S1 (x2 ) = a1 + b1 (x2 x1 ) + c1 (x2 x1 )2 + d1 (x2 x1 )3 = 1 + b1 + c1 + d1 ,
2

two smoothness conditions: S00 (x1 ) = S10 (x1 ) and S000 (x1 ) = S100 (x1 ). Thus respectively
b0 + 2c0 (x1 x0 ) + 3d0 (x1 x0 )2 = b1 + 2c1 (x1 x1 ) + 3d1 (x1 x1 )2
and
2c0 + 6d0 (x1 x0 ) = 2c1 + 6d1 (x1 x1 ).
By plugging in all the values we know they reduce to
b0 + 2c0 + 3d0 = b1
and
2c0 + 6d0 = 2c1 .
Two extra conditions: the free boundary conditions S 00 (x0 ) = 0 and S 00 (x2 ) = 0
simplify to
2c0 + 6d0 = 0
and
2c1 + 6d1 = 0.
All the equations are there. Let us summarize them into one list of eight.

a0

=0

a1

=1

b0 + c0 + d0

=1

1 + b1 + c1 + d1

=2

b0 + 2c0 + 3d0

2c0 + 6d0

2c0 + 6d0

2c1 + 6d1

= b1
= 2c1
=0
=0

One can either pour this system into matrix shape or attempt to solve it in a sequential
manner. We will do the latter. Equation six and seven imply c1 = 0. Equation eight
3

implies d1 = 0. Equation four implies b1 = 1. The system reduces to

a0
=0

a1
=1

=1

b0 + c0 + d0

b
=1
1

b0 + 2c0 + 3d0 = 1

c1
=0

2c0 + 6d0
=0

d1
= 0.
Combining equations three and five gets
c0 + 2d0 = 0
which leads to c0 = 0 and d0 = 0 when combined with equation seven. This also means
b0 = 1. Conclusion is that the cubic spline is in this case

S (x) = x
if x [0, 1)
0
S(x) =
S1 (x) = 1 + (x 1) = x if x [1, 2).
This makes sense because the function f could have just been f (x) = x.
Quadratic and quartic splines are defined in a similar way by expanding or trimming the
list of smoothness conditions.

You might also like