Date post: | 20-Feb-2015 |
Category: |
Documents |
Upload: | surender-reddy |
View: | 29 times |
Download: | 0 times |
MATH2601 Chapter 3 Approximating Functions 118
3.3 Spline Interpolation
A spline function consists of polynomial pieces on subintervals
joined together with certain continuity conditions.
Formally, suppose that n + 1 points t0, t1, · · · , tn have been
specified and satisfy
t0 < t1 < · · · < tn
These points are called knots.
Suppose also that an integer k ≥ 0 has been prescribed. A spline
function of degree k having knots t0, t1, · · · , tn is a function
S such that:
1. On each interval [ti−1, ti], S is a polynomial of degree ≤ k.
2. S has a continuous (k − 1)st derivative on [t0, tn].
Hence, S is a piecewise polynomial of degree at most k having
continuous derivatives of all orders up to k − 1.
MATH2601 Chapter 3 Approximating Functions 119
Figure 7: A spline of degree 0
Splines of degree 0 are piecewise constants. A typical spline of
degree 0 with six knots is shown in Figure 7.
A spline of degree 0 can be given explicitly in the form
S(x) =
S0(x) = c0 x ∈ [t0, t1)
S1(x) = c1 x ∈ [t1, t2)... ...
Sn−1(x) = cn−1 x ∈ [tn−1, tn]
The intervals [ti−1, ti) do not intersect each other, and so no
ambiguity arises in defining such a function at the knots.
MATH2601 Chapter 3 Approximating Functions 120
Figure 8: A spline of degree 1
Figure 8 shows the graph of a typical spline function of degree 1
with nine knots. A function such as this can be defined explicitly
by
S(x) =
S0(x) = a0x + b0 x ∈ [t0, t1]
S1(x) = a1x + b1 x ∈ [t1, t2]... ...
Sn−1(x) = an−1x + bn−1 x ∈ [tn−1, tn]
The function S is continuous, and so the piecewise polynomials
match up at the knots; that is, Si(ti+1) = Si+1(ti+1).
◦ If the knots ti and the coefficients ai, bi are all prescribed,
then the value of S at x is obtained by first identifying the
subinterval [ti, ti+1) that contains x.
MATH2601 Chapter 3 Approximating Functions 121
◦ The spline function can be defined on the entire real line.
For convenience, we can use the expression a0x + b0 on the
interval (−∞, t1) and the expression an−1x + bn−1 on the
interval [tn−1,∞).
Example 3.13 Determine whether the following function is a
quadratic spline.
f(x) =
x x ∈ (−∞, 1]
−1
2(2 − x)2 + 3
2x ∈ [1, 2]
3
2x ∈ [2,∞)
Solution It is easy to see that
f ′(x) =
1 x ∈ (−∞, 1]
2 − x x ∈ [1, 2]
0 x ∈ [2,∞)
Since
limx→1−
f(x) = 1 = limx→1+
f(x)
limx→2−
f(x) =3
2= lim
x→2+f(x)
limx→1−
f ′(x) = 1 = limx→1+
f ′(x)
limx→2−
f ′(x) = 0 = limx→2+
f ′(x)
we see that both f and f ′ are continuous on R. So f is a
quadratic spline.
MATH2601 Chapter 3 Approximating Functions 122
Example 3.14 Is the function in Example 3.13 a cubic spline?
Solution Note that
f ′′(x) =
0 x ∈ (−∞, 1]
−1 x ∈ [1, 2]
0 x ∈ [2,∞)
Since
limx→1−
f ′′(x) = 0 6= −1 = limx→1+
f ′′(x)
By definition, f is not a cubic spline function since f ′′ is not
continuous.
Example 3.15 If S is a first degree spline function that inter-
polates f at a sequence of knots 0 = t0 < t1 < · · · < tn = 1,
what is∫
1
0S(x) dx?
Solution Suppose the given table of values is
x t0 t1 t2 · · · tn
y y0 y1 y2 · · · yn
and
S(x) =
S0(x) = a0x + b0 x ∈ [t0, t1)
S1(x) = a1x + b1 x ∈ [t1, t2)... ...
Sn−1(x) = an−1x + bn−1 x ∈ [tn−1, tn]
MATH2601 Chapter 3 Approximating Functions 123
Then∫
1
0
S(x) dx =
n−1∑
i=0
∫ ti+1
ti
(aix + bi) dx
=n−1∑
i=0
[ai
2(t2i+1 − t2i ) + bi(ti+1 − ti)
]
=n−1∑
i=0
[ai
2(ti+1 + ti) + bi
]
(ti+1 − ti)
=n−1∑
i=0
[
1
2(aiti+1 + bi + aiti + bi)
]
(ti+1 − ti)
=n−1∑
i=0
1
2(yi+1 + yi)(ti+1 − ti)
Remark If f is nonnegative, then so is S. In this case,∫
1
0S(x) dx
is the sum of area of trapezoids over [ti, ti+1].
MATH2601 Chapter 3 Approximating Functions 124
Example 3.16 Determine all the values of a, b, c, d, e for which
the following function is a cubic spline:
f(x) =
a(x − 2)2 + b(x − 1)3 x ∈ (−∞, 1]
c(x − 2)2 x ∈ [1, 3]
d(x − 2)2 + e(x − 3)3 x ∈ [3,∞)
Next, determine the value of parameters so that the cubic spline
interpolates this table
x 0 1 4
y 26 7 25
Solution From the definition of f , we deduce that
f ′(x) =
2a(x − 2) + 3b(x − 1)2 x ∈ (−∞, 1]
2c(x − 2) x ∈ [1, 3]
2d(x − 2) + 3e(x − 3)2 x ∈ [3,∞)
and
f ′′(x) =
2a + 6b(x − 1) x ∈ (−∞, 1]
2c x ∈ [1, 3]
2d + 6e(x − 3) x ∈ [3,∞)
MATH2601 Chapter 3 Approximating Functions 125
The continuity of f , f ′ and f ′′ at x = 1 and x = 3 implies the
following, respectively:
f : a = c and c = d
f ′ : −2a = −2c and 2c = 2d
f ′′ : 2a = 2c and 2c = 2d
So a = c = d. Therefore f is a cubic spline iff a = c = d, and
b and e can take any values. (There are only three degrees of
freedom.)
According to the table, f(0) = 26, f(1) = 7, and f(4) = 25, so
4a − b = 26
c = 7
4d + e = 25
In addition, a = c = d. Therefore the values of these parameters
can be uniquely determined:
a = c = d = 7, b = 2 and e = −3
MATH2601 Chapter 3 Approximating Functions 126
Cubic Splines
We shall develop more thoroughly the theory and construction of
the cubic splines (k = 3) since these are often used in practice.
We assume that a table of values has been given:
x t0 t1 t2 · · · tn
y y0 y1 y2 · · · yn
(3.22)
and that a cubic spline S it to be constructed to interpolate the
table.
On each interval [t0, t1], [t1, t2], · · · , [tn−1, tn], S is given by a
different cubic polynomial.
Let Si be the cubic polynomial that represents S on [ti, ti+1].
Thus,
S(x) =
S0(x) x ∈ [t0, t1]
S1(x) x ∈ [t1, t2]... ...
Sn−1(x) x ∈ [tn−1, tn]
(3.23)
MATH2601 Chapter 3 Approximating Functions 127
The polynomials
Si−1 on [ti−1, ti]
and
Si on [ti, ti+1]
interpolate the same value at the point ti and therefore
Si−1(ti) = yi = Si(ti) (1 ≤ i ≤ n − 1)
Hence, S is automatically continuous.
Moreover, S ′ and S ′′ are assumed to be continuous, and these
conditions will be used in the derivation of the cubic spline func-
tion.
MATH2601 Chapter 3 Approximating Functions 128
Does the continuity of S, S ′ and S ′′ provide enough conditions
to define a cubic spline?
There are 4n coefficients in the piecewise cubic polyno-
mial since there are four coefficients in each of the n cubic
polynomials.
◦ On each subinterval [ti, ti+1], there are two interpolation con-
ditions, S(ti) = yi and S(ti+1) = yi+1, giving 2n conditions.
◦ The continuity of S gives no additional conditions since it has
already been counted in the interpolation conditions.
◦ The continuity of S ′ gives one condition at each interior knot,
S ′i−1(ti) = S ′
i(ti)
accounting for n − 1 additional conditions.
◦ Similarly, the continuity of S ′′ gives another n− 1 conditions.
Thus there are altogether 4n − 2 conditions for determining 4n
coefficients. Two degrees of freedom remain, and there are
various ways of using them to advantage.
MATH2601 Chapter 3 Approximating Functions 129
Now we derive the equation for Si(x) on the interval [ti, ti+1].
1. First we define the numbers zi = S ′′(ti). Clearly, zi exists for
0 ≤ i ≤ n an satisfy
limx→t+i
S ′′(x) = zi = limx→t−i
S ′′(x) (1 ≤ i ≤ n − 1)
because S ′′ is continuous at each interior knot.
2. Since Si is a polynomial of degree 3 on [ti, ti+1], S ′′i is a poly-
nomial of degree 1. We may write
S ′′i (x) = Aix + Bi, x ∈ [ti, ti+1]
Note that S ′′i satisfies
S ′′i (ti) = zi and S ′′
i (ti+1) = zi+1
Then
Aiti + Bi = zi
Aiti+1 + Bi = zi+1
Let hi = ti+1 − ti, we have
Ai =zi+1 − zi
ti+1 − ti=
zi+1 − zi
hi
Bi = zi − Aiti = zi −zi+1 − zi
hiti
MATH2601 Chapter 3 Approximating Functions 130
Hence
S ′′i (x) = Aix + Bi
=zi+1 − zi
hix + zi −
zi+1 − zi
hiti
=zi+1
hix −
zi+1
hiti + zi −
zi
hix +
zi
hiti
=zi+1
hi(x − ti) + zi −
zi
hix +
zi
hi(ti+1 − hi)
=zi+1
hi(x − ti) + zi −
zi
hix +
zi
hiti+1 − zi
=zi+1
hi(x − ti) +
zi
hi(ti+1 − x)
So S ′′i (x) is the straight line between zi and zi+1:
S ′′i (x) =
zi
hi(ti+1 − x) +
zi+1
hi(x − ti) (3.24)
If this is integrated once,
S ′i(x) =
zi
hi
∫
(ti+1 − x) dx +zi+1
hi
∫
(x − ti) dx
= −1
2
zi
hi(ti+1 − x)2 +
1
2
zi+1
hi(x − ti)
2 + Ci
Integrating one more time, the result is Si itself:
Si(x) =zi
6hi(ti+1 − x)3 +
zi+1
6hi(x − ti)
3
+ Ci(x − ti) + Di (3.25)
MATH2601 Chapter 3 Approximating Functions 131
3. The interpolation conditions Si(ti) = yi and Si(ti+1) = yi+1
can now be imposed on Si to determine Ci and Di.
First,
yi =zi
6hi(ti+1 − ti)
3 + Di =⇒ Di = yi −zih
2i
6
Then
yi+1 =zi+1
6hi(ti+1 − ti)
3 + Ci(ti+1 − ti) + Di
leads to
Ci =yi+1 − yi
hi+
hi
6(zi − zi+1)
Hence
Si(x) =zi
6hi(ti+1 − x)3 +
zi+1
6hi(x − ti)
3
+
[
yi+1 − yi
hi+
hi
6(zi − zi+1)
]
(x − ti)
+
(
yi −zih
2i
6
)
which can be rewritten as
Si(x) =zi
6hi(ti+1 − x)3 +
zi+1
6hi(x − ti)
3
+
(
yi+1
hi−
zi+1hi
6
)
(x − ti)
+
(
yi
hi−
zihi
6
)
(ti+1 − x) (3.26)
MATH2601 Chapter 3 Approximating Functions 132
4. Once the values of z0, z1, · · · , zn have been determined,
(3.23) and (3.26) can be used to evaluate S(x) for any x in
the interval [t0, tn].
5. To determine z1, z2, · · · , zn−1, we use the continuity condi-
tions for S ′ at the interior knots ti:
S ′i−1(ti) = S ′
i(ti)
Since
S ′i(x) = −
1
2
zi
hi(ti+1 − x)2 +
1
2
zi+1
hi(x − ti)
2
+yi+1 − yi
hi+
hi
6(zi − zi+1)
Then substitution of x = ti and simplification lead to
S ′i(ti) = −
hi
3zi −
hi
6zi+1 +
yi+1 − yi
hi(3.27)
and
S ′i−1(ti) =
hi−1
6zi−1 +
hi−1
3zi +
yi − yi−1
hi−1
(3.28)
When the right-hand sides of (3.27) and (3.28) are set equal
to each other, the result can be written as
hi−1zi−1 + 2(hi + hi−1)zi + hizi+1
=6
hi(yi+1 − yi) −
6
hi−1
(yi − yi−1) (3.29)
MATH2601 Chapter 3 Approximating Functions 133
If we define
ci =6
hi(yi+1 − yi)
then
6
hi(yi+1 − yi) −
6
hi−1
(yi − yi−1) = ci − ci−1
Let
bi = ci − ci−1
Then (3.29) can be written as
hi−1zi−1 + 2(hi + hi−1)zi + hizi+1 = bi (3.30)
which is valid only for i = 1, 2, · · · , n − 1. (Why?)
◦ (3.29) gives a system of n−1 linear equations for the n+1
unknowns z0, z1, · · · , zn.
◦ Recall that we have 2 degrees of freedom.
We can select z0 and zn arbitrarily and solve the resulting system
of equations to obtain z1, z2, · · · , zn−1.
One widely used choice is z0 = zn = 0. The resulting spline
function is called natural cubic spline. (This choice of spline
is supported by a theorem to be proved later.)
MATH2601 Chapter 3 Approximating Functions 134
Equations (3.30) for 1 ≤ i ≤ n− 1 with z0 = 0 and zn = 0 leads
to a linear system of the following form.
u1 h1
h1 u2 h2
h2 u3 h3
. . . . . . . . .
hn−3 un−2 hn−2
hn−2 un−1
z1
z2
z3
...
zn−2
zn−1
=
b1
b2
b3
...
bn−2
bn−1
where
ui = 2(hi + hi−1) hi = ti+1 − ti
bi = ci − ci−1 ci =6
hi(yi+1 − yi)
◦ The coefficient matrix is symmetric, tridiagonal and diagonally
dominant.
◦ Hence Gaussian elimination without pivoting can be used to
solve the system for z1, z2, · · · , zn−1.
◦ Once zi are computed, Si(x) can be determined.
MATH2601 Chapter 3 Approximating Functions 135
Example 3.17 Find the natural cubic spline function whose
knots are −1, 0 and 1 and that takes the value S(−1) = 13,
S(0) = 7 and S(1) = 9.
Solution We need z0 = z2 = 0.
Now
t0 = −1, t1 = 0, t2 = 1,
y0 = 13, y1 = 7, y2 = 9
and
h0 = h1 = 1
So (3.29) yields
h0z0 + 2(h1 + h0)z1 + h1z2 =6
h1
(y2 − y1) −6
h0
(y1 − y0)
2(2)z1 = 6(2) − 6(−6)
which implies z1 = 12.
By (3.26), we have
S0(x) =z0
6h0
(t1 − x)3 +z1
6h0
(x − t0)3 +
(
y1
h0
−z1h0
6
)
(x − t0)
+
(
y0
h0
−z0h0
6
)
(t1 − x)
=z1
6h0
(x − t0)3 +
(
y1
h0
−z1h0
6
)
(x − t0) +y0
h0
(t1 − x)
= 2(x + 1)3 + 5(x + 1) − 13x
MATH2601 Chapter 3 Approximating Functions 136
and
S1(x) =z1
6h1
(t2 − x)3 +z2
6h1
(x − t1)3 +
(
y2
h1
−z2h1
6
)
(x − t1)
+
(
y1
h1
−z1h1
6
)
(t2 − x)
=z1
6h1
(t2 − x)3 +y2
h1
(x − t1) +
(
y1
h1
−z1h1
6
)
(t2 − x)
= 2(1 − x)3 + 9x + 5(1 − x)
So the natural cubic spline function is
S(x) =
{
2(x + 1)3 + 5(x + 1) − 13x x ∈ [−1, 0]
2(1 − x)3 + 9x + 5(1 − x) x ∈ [0, 1]
We now present a theorem to the effect that the natural spline
produces the smoothest possible interpolating function. The
word smooth is given a technical meaning in the theorem.
Theorem 3.6. (Theorem on Optimality of Natural Cubic
Splines) Let f ′′ be continuous on [a, b] and let a = t0 < t1 <
· · · < tn = b. If S is the natural cubic spline interpolating f at
the knots ti for 0 ≤ i ≤ n, then∫ b
a
[S ′′(x)]2 dx ≤
∫ b
a
[f ′′(x)]2 dx
MATH2601 Chapter 3 Approximating Functions 137
Proof We need to show∫ b
a
[S ′′(x)]2 dx ≤
∫ b
a
[f ′′(x)]2 dx
Let g ≡ f − S. Then
g(ti) = 0 for 0 ≤ i ≤ n
and (f ′′)2 = (S ′′ + g′′)2 = (S ′′)2 + (g′′)2 + 2S ′′g′′ leads to∫ b
a
(f ′′)2 dx =
∫ b
a
(S ′′)2 dx +
∫ b
a
(g′′)2 dx + 2
∫ b
a
S ′′g′′ dx
The proof will be complete if we can show that∫ b
a S ′′g′′ dx ≥ 0.
We establish this in the following analysis, using integration by
parts, the condition S ′′(t0) = S ′′(tn) = 0, and the fact that S ′′′
is a constant (say ci) on [ti−1, ti].∫ b
a
S ′′g′′ dx =n
∑
i=1
∫ ti
ti−1
S ′′g′′ dx
=
n∑
i=1
{
(S ′′g′)(ti) − (S ′′g′)(ti−1) −
∫ ti
ti−1
S ′′′g′ dx
}
= −n
∑
i=1
∫ ti
ti−1
S ′′′g′ dx = −n
∑
i=1
ci
∫ ti
ti−1
g′ dx
= −n
∑
i=1
ci[g(ti) − g(ti − 1)] = 0
MATH2601 Chapter 3 Approximating Functions 138
Theorem 3.7. Let a = t0 < t1 < · · · < tn = b. If g′′ is
continuous on [a, b] and g interpolates a given function f at the
knots ti for 0 ≤ i ≤ n, then∫ b
a
[S ′′(x)]2 dx ≤
∫ b
a
[g′′(x)]2 dx
where S is the natural cubic spline interpolating f at the knots
ti for 0 ≤ i ≤ n.
Proof Since S also interpolates g at ti for 0 ≤ i ≤ n, the
statement can be decuded directly from Theorem (3.6) with g in
place of f over there.
Remark For a curve defined by the equation y = g(x), the
curvature at a point x is
k(x) =|g′′(x)|
(1 + |g′(x)|2)3/2
which is commonly linearized to
k(x) ≈ |g′′(x)|
The quantity∫ b
a [g′′(x)]2 dx can therefore be viewed as a crude
measure of the total curvature over an interval.
In this measure, Theorem (3.7) asserts that any smooth interpo-
lating function must have a total curvature at least as large as
that of the natural cubic spline. That is why the natural spline
produces the smoothest possible interpolating function.
MATH2601 Chapter 3 Approximating Functions 139
Example 3.18 Determine the values of a, b, c so that the fol-
lowing function is a cubic spline having knots 0, 1 and 2:
f(x) =
{
3 + x − 9x2 x ∈ [0, 1]
a + b(x − 1) + c(x − 1)2 + d(x − 1)3 x ∈ [1, 2]
Next, determine d so that∫
2
0[f ′′(x)]2 dx is minimized. Finally,
find the value of d that makes f ′′(2) = 0 and explain why this
value is different from the one previously determined.
Solution Observe that
f ′(x) =
{
1 − 18x x ∈ [0, 1]
b + 2c(x − 1) + 3d(x − 1)2 x ∈ [1, 2]
and
f ′′(x) =
{
−18 x ∈ [0, 1]
2c + 6d(x − 1) x ∈ [1, 2]
The continuity of f , f ′ and f ′′ at x = 1 implies the following,
respectively:
f : −5 = a
f ′ : −17 = b
f ′′ : −18 = 2c
So a = −5, b = −17 and c = −9.
MATH2601 Chapter 3 Approximating Functions 140
Since∫
2
0
[f ′′(x)]2 dx
=
∫
1
0
[f ′′(x)]2 dx +
∫
2
1
[f ′′(x)]2 dx
=
∫
1
0
[−18]2 dx +
∫
2
1
[2c + 6d(x − 1)]2 dx
= 2(18)2 − 108d + 12d2 (as c = −9)
it can be seen that∫
2
0[f ′′(x)]2 dx is minimized when the first
derivative −108 + 24d = 0. Thus d = 9/2.
Setting f ′′(2) = 0 yields 2c + 6d = 0, so d = 3.
Since f ′′(0) = −18, f(x) is not a natural cubic spline for any d.
So when∫
2
0[f ′′(x)]2 dx is minimized, we need not have f ′′(2) = 0.
That is why the above values of d can be different.