Cubic Splines: Interpolating Data with Continuous Derivatives - Prof. Jeffery M. Cooper, Study notes of Mathematics

The concept of cubic splines, a function defined piecewise with each piece being a cubic polynomial. The interpolation of data points using cubic polynomials, the continuity of the derivative, and the determination of the constants using divided differences. Three types of splines are discussed: complete splines, natural splines, and not a knot splines.

Typology: Study notes

Pre 2010

Uploaded on 07/30/2009

koofers-user-g5x
koofers-user-g5x 🇺🇸

10 documents

1 / 3

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
SPLINES
A cubic spline is a function defined piecewise with each piece being a cubic
polynomial. Let the break points (knots) be x1< x2< . . . < xn, and let
y1, y2,...,ynbe the data values at these points. We set
δk=yk+1 yk
xk+1 xk
.
There are n1 subintervals xkxxk+1 and a cubic polynomial Pk(x)
defined on each subinterval. Using s=xxk, and h=xk+1 xk, we write the
polynomials in the form
Pk(x) = Pk(s) = 3hs22s3
h3yk+1 +h3hs2+ 2s3
h3yk(1)
+s2(sh)
h2dk+1 +s(sh)2
h2dk.
With the polynomials written this way, it is easy to verify that Pk(xk) =
Pk(s= 0) = yk, and Pk(xk+1) = Pk(s=h) = yk+1 . Thus P=Pkinterpolates
the data points (xk, yk). The piecewise defined function P=Pkalso has a
continuous derivative. In fact you can verify that P
k(xk) = P
k(s= 0) = dk,
and P
k(xk+1) = P
k(s=h) = dk+1.
We still have the nconstants d1,...,dnto determine. If we knew a function
f(x) such that f(xk) = yk, we could just set dk=f(xk). Another approach is
to determine the values for the dkusing the values of the divided differences δk.
This is the method used in constructing the Shape-Preserving Piecewise Cubic,
described in Moler, p100 and in the MATLAB code pchip.m.
In a spline, we impose other conditions on Pat the knots to determine the dk.
We shall require that P′′ be continuous at the interior knots xk, k = 2,...,n1:
P
k(x+
k) = P′′
k1(x
k), k = 2,...,n1.
This yields the equations for the dk(k= 2,...,n1):
hkdk1+ 2(hk1+hk)dk+hk1dk+1 = 3(hkδk1+hk1δk).(2)
We now have n2 equations for the nunknowns dk. To make a system
that has a unique solution for the dk, we must add two equations to the n2
equations (2) or remove two unknowns. This can be done in several ways by
imposing extra conditions at the ends.
Complete Spline We assign values to d1and dnusing other outside in-
formation. For example, we can interpolate a parabola r(x) through the data
points (x1, y1),(x2, y2),(x3, y3), and take d1=r(x1). Do the same thing at the
other end. Since d1and dnare considered known, we can put them to the other
side of equation in the first equation (k = 2) of (2) and in the last equation (k =
1
pf3

Partial preview of the text

Download Cubic Splines: Interpolating Data with Continuous Derivatives - Prof. Jeffery M. Cooper and more Study notes Mathematics in PDF only on Docsity!

SPLINES

A cubic spline is a function defined piecewise with each piece being a cubic

polynomial. Let the break points (knots) be x 1 < x 2 <... < xn, and let

y 1 , y 2 ,... , yn be the data values at these points. We set

δk =

yk+1 − yk

xk+1 − xk

There are n − 1 subintervals xk ≤ x ≤ xk+1 and a cubic polynomial Pk(x)

defined on each subinterval. Using s = x − xk, and h = xk+1 − xk, we write the

polynomials in the form

Pk(x) = Pk(s) =

3 hs

2 − 2 s

3

h 3

yk+1 +

h

3 − hs

2

  • 2s

3

h 3

yk (1)

s 2 (s − h)

h 2

dk+1 +

s(s − h) 2

h 2

dk.

With the polynomials written this way, it is easy to verify that Pk(xk) =

Pk(s = 0) = yk, and Pk(xk+1) = Pk(s = h) = yk+1. Thus P = ∪Pk interpolates

the data points (xk, yk). The piecewise defined function P = ∪Pk also has a

continuous derivative. In fact you can verify that P

′ k (xk) = P

′ k (s = 0) = dk,

and P

′ k (xk+1) = P

′ k (s = h) = dk+1.

We still have the n constants d 1 ,... , dn to determine. If we knew a function

f (x) such that f (xk) = yk, we could just set dk = f

′ (xk). Another approach is

to determine the values for the dk using the values of the divided differences δk.

This is the method used in constructing the Shape-Preserving Piecewise Cubic,

described in Moler, p100 and in the MATLAB code pchip.m.

In a spline, we impose other conditions on P at the knots to determine the dk.

We shall require that P

′′ be continuous at the interior knots xk, k = 2,... , n−1:

P

′ k(x

k

) = P

′′ k− 1 (x

− k ), k = 2,... , n − 1.

This yields the equations for the dk (k = 2,... , n − 1):

hkdk− 1 + 2(hk− 1 + hk)dk + hk− 1 dk+1 = 3(hkδk− 1 + hk− 1 δk). (2)

We now have n − 2 equations for the n unknowns dk. To make a system

that has a unique solution for the dk, we must add two equations to the n − 2

equations (2) or remove two unknowns. This can be done in several ways by

imposing extra conditions at the ends.

Complete Spline We assign values to d 1 and dn using other outside in-

formation. For example, we can interpolate a parabola r(x) through the data

points (x 1 , y 1 ), (x 2 , y 2 ), (x 3 , y 3 ), and take d 1 = r

′ (x 1 ). Do the same thing at the

other end. Since d 1 and dn are considered known, we can put them to the other

side of equation in the first equation (k = 2) of (2) and in the last equation (k =

n-1) of (2). This yields the n − 2 × n − 2 system T d = r with d = (d 2 ,... , dn− 1 )

and the n − 2 × n − 2 matrix T is

T =

2(h 2 + h 1 ) h 1

h 3 2(h 3 + h 2 ) h 2

hn− 1 2(hn− 2 + hn− 1 )

and

r =

3(h 1 δ 2 + h 2 δ 1 ) − d 1 h 2

3(h 2 δ 3 + h 3 δ 2 )

·

·

3(hn− 2 δn− 1 + hn− 1 δn− 2 ) − dnhn− 2

Natural Spline We set P ′′ 1 (x 1 ) = 0 and P ′′ n− 1 (xn) = 0. This yields the

two additional equations

2 d 1 + d 2 = 3δ 1 and dn− 1 + 2dn = 3δn− 1.

Combining these two equations with the equations (2), we have the matrix

equation Sd = r where d = (d 1 ,... , dn),

r = 3

δ 1

h 1 δ 2 + h 2 δ 1

h 2 δ 3 + h 3 δ 2

·

·

hn− 2 δn− 1 + hn− 1 δn− 2

δn− 1

and the n × n matrix S

S =

h 2 2(h 2 + h 1 ) h 1

h 3 2(h 3 + h 2 ) h 2

hn− 1 2(hn− 2 + hn− 1 ) hn− 2

1 2

Not a Knot Spline In this type of spline, we obtain two additional condi-

tions by requiring P ′′′ to be continuous at x 2 and at xn− 1. This is equivalent to

using a single cubic to interpolate the data at x 1 , x 2 and x 3 , and a single cubic

to interpolate the data at xn− 2 , xn− 1 and xn.

If we calculate three derivatives of P from formula (1), we see that on the

k th subinterval, P ′′′ k is the constant

P

′′′ k (s)^ ≡

− 12 δk + 6(dk+1 + dk)

h

2 k