Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Standard view
Full view
of .
0 of .
Results for:
P. 1
Cubic Spline Interpolation

# Cubic Spline Interpolation

Ratings: (0)|Views: 899|Likes:

### Availability:

See more
See less

04/17/2013

pdf

text

original

Cubic Spline Interpolation
Sky McKinley and Megan Levine
Math 45: Linear Algebra
Abstract
. An introduction into the theory and application of cubic splines with accompanying Matlabm-file cspline.m
Introduction
Real world numerical data is usually difficult to analyze. Any function which wouldeffectively correlate the data would be difficult to obtain and highly unwieldy. To this end,the idea of the cubic spline was developed. Using this process, a series of unique cubicpolynomials are fitted between each of the data points, with the stipulation that the curveobtained be continuous and appear smooth. These cubic splines can then be used todetermine rates of change and cumulative change over an interval. In this brief introduction,we will only discuss splines which interpolate equally spaced data points, although a morerobust form could encompass unequally spaced points.
Theory
The fundamental idea behind cubic spline interpolation is based on the engineer’s toolused to draw smooth curves through a number of points. This spline consists of weightsattached to a flat surface at the points to be connected. A flexible strip is then bent acrosseach of these weights, resulting in a pleasingly smooth curve.The mathematical spline is similar in principle. The points, in this case, are numericaldata. The weights are the coefficients on the cubic polynomials used to interpolate the data.These coefficients ’bend’ the line so that it passes through each of the data points withoutany erratic behavior or breaks in continuity.
Process
The essential idea is to fit a piecewise function of the form
S
Ý
x
Þ
=
s
1
Ý
x
Þ
if
x
1
²
x
<
x
2
s
2
Ý
x
Þ
if
x
2
²
x
<
x
3
_
s
n
?
1
Ý
x
Þ
if
x
n
?
1
²
x
<
x
n
(1)where
s
i
is a third degree polynomial defined by
s
i
Ý
x
Þ
=
a
i
Ý
x
?
x
i
Þ
3
+
b
i
Ý
x
?
x
i
Þ
2
+
c
i
Ý
x
?
x
i
Þ
+
i
(2)for
i
=
1,2,...,
n
?
1.The first and second derivatives of these
n
?
1 equations are fundamental to this process,and they are1

2
s
i
v
Ý
x
Þ
=
3
a
i
Ý
x
?
x
i
Þ
2
+
2
b
i
Ý
x
?
x
i
Þ
+
c
i
s
i
vv
Ý
x
Þ
=
6
a
i
Ý
x
?
x
i
Þ
+
2
b
i
(3) (4)for
i
=
1,2,...,
n
?
1.
The Four Properties of Cubic Splines
Our spline will need to conform to the following stipulations.1. The piecewise function
S
Ý
x
Þ
will interpolate all data points.2.
S
Ý
x
Þ
will be continuous on the interval
ß
x
1
,
x
n
à
3.
S
v
Ý
x
Þ
will be continuous on the interval
ß
x
1
,
x
n
à
4.
S
vv
Ý
x
Þ
will be continuous on the interval
ß
x
1
,
x
n
à
Since the piecewiece function
S
Ý
x
Þ
will interpolate all of the data points, we canconclude that
S
Ý
x
i
Þ
=
y
i
(5)for
i
=
1,2,...,
n
?
1. Since
x
i
5
ß
x
i
,
x
i
+
1
à
,
S
Ý
x
i
Þ
=
s
i
Ý
x
i
Þ
and we can use equation (2) toproduce
y
i
=
s
i
Ý
x
i
Þ
y
i
=
a
i
Ý
x
i
?
x
i
Þ
3
+
b
i
Ý
x
i
?
x
i
Þ
2
+
c
i
Ý
x
i
?
x
i
Þ
+
i
y
i
=
i
(6)for each
i
=
1,2,...,
n
?
1.Since the curve
S
Ý
x
Þ
must be continuous across its entire interval, it can be concludedthat each sub-function must join at the data points, so
s
i
Ý
x
i
Þ
=
s
i
?
1
Ý
x
i
Þ
(7)for
i
=
2,3,...,
n
.From equation (2),
s
i
Ý
x
i
Þ
=
i
and
s
i
?
1
Ý
x
i
Þ
=
a
i
?
1
Ý
x
i
?
x
i
?
1
Þ
3
+
b
i
?
1
Ý
x
i
?
x
i
?
1
Þ
2
+
c
i
?
1
Ý
x
i
?
x
i
?
1
Þ
+
i
?
1
(8)so
i
=
a
i
?
1
Ý
x
i
?
x
i
?
1
Þ
3
+
b
i
?
1
Ý
x
i
?
x
i
?
1
Þ
2
+
c
i
?
1
Ý
x
i
?
x
i
?
1
Þ
+
i
?
1
(9)for
i
=
2,3,...,
n
?
1. Letting
h
=
x
i
?
x
i
?
1
in equation (8), we have
i
=
a
i
?
1
h
3
+
b
i
?
1
h
2
+
c
i
?
1
h
+
i
?
1
(10)for
i
=
2,3,...,
n
?
1.Also, to make the curve smooth across the interval, the derivatives must be equal at thedata points; that is,
s
i
v
Ý
x
i
Þ
=
s
i
?
1
v
Ý
x
i
Þ
(11)

3However, by equation (3),
s
i
v
Ý
x
i
Þ
=
c
i
and
s
i
?
1
v
Ý
x
i
Þ
=
3
a
i
?
1
Ý
x
i
?
x
i
?
1
Þ
2
+
2
b
i
?
1
Ý
x
i
?
x
i
?
1
Þ
+
c
i
?
1
so
c
i
=
3
a
i
?
1
Ý
x
i
?
x
i
?
1
Þ
2
+
2
b
i
?
1
Ý
x
i
?
x
i
?
1
Þ
+
c
i
?
1
. (12)Again, letting
h
=
x
i
?
x
i
?
1
, we arrive at
c
i
=
3
a
i
?
1
h
2
+
2
b
i
?
1
h
+
c
i
?
1
(13)for
i
=
2,3,
u
,
n
?
1.From equation (4),
s
i
vv
Ý
x
Þ
=
6
a
i
Ý
x
?
x
i
Þ
+
2
b
i
, so
s
i
vv
Ý
x
Þ
=
6
a
i
Ý
x
?
x
i
Þ
+
2
b
i
s
i
vv
Ý
x
i
Þ
=
6
a
i
Ý
x
i
?
x
i
Þ
+
2
b
i
s
i
vv
Ý
x
i
Þ
=
2
b
i
(14)for
i
=
2,3,...,
n
?
2.Lastly, since
s
i
vv
Ý
x
Þ
has to be continuous across the interval,
s
i
vv
Ý
x
i
Þ
=
s
i
+
1
vv
Ý
x
i
Þ
for
i
=
1,2,3,
`
,
n
?
1. This and equation (14) lead us to the equation
s
i
vv
Ý
x
i
+
1
Þ
=
6
a
i
Ý
x
i
+
1
?
x
i
Þ
+
2
b
i
s
i
+
1
vv
Ý
x
i
+
1
Þ
=
6
a
i
Ý
x
i
+
1
?
x
i
Þ
+
2
b
i
(15) (16)and, letting
h
=
x
i
+
1
?
x
i
and using the conclusion from equations (14) and (16),
s
i
+
1
vv
Ý
x
i
+
1
Þ
=
6
a
i
Ý
x
i
+
1
?
x
i
Þ
+
2
b
i
2
b
i
+
1
=
6
a
i
h
+
2
b
i
(17) (18)These equations can be much simplified by substituting
i
for
s
i
vv
Ý
x
i
Þ
and expressing theabove equations in terms of
i
and
y
i
. This makes the determination of the weights
a
i
,
b
i
,
c
i
, and
i
b
i
can be represented by
s
i
vv
Ý
x
i
Þ
=
2
b
i
M
i
=
2
b
i
b
i
=
i
2 (19)and
i
has already been determined to be
i
=
y
i
. (20)Similarly, using equation
a
i
can be re-written as