Lecture 11 W
Lecture 11 W
b. Derive the error term in Theorem 3.9. [Hint: Use the same method as in the Lagrange error
derivation, Theorem 3.3, defining
(t − x0 )2 · · · (t − xn )2
g(t) = f (t) − H2n+1 (t) − [f (x) − H2n+1 (x)]
(x − x0 )2 · · · (x − xn )2
and using the fact that g (t) has (2n + 2) distinct zeros in [a, b].]
12. Let z0 = x0 , z1 = x0 , z2 = x1 , and z3 = x1 . Form the following divided-difference table.
z0 = x0 f [z0 ] = f (x0 )
f [z0 , z1 ] = f (x0 )
z1 = x0 f [z1 ] = f (x0 ) f [z0 , z1 , z2 ]
f [z1 , z2 ] f [z0 , z1 , z2 , z3 ]
z2 = x1 f [z2 ] = f (x1 ) f [z1 , z2 , z3 ]
f [z2 , z3 ] = f (x1 )
z3 = x1 f [z3 ] = f (x1 )
Show that the cubic Hermite polynomial H3 (x) can also be written as f [z0 ] + f [z0 , z1 ](x − x0 ) +
f [z0 , z1 , z2 ](x − x0 )2 + f [z0 , z1 , z2 , z3 ](x − x0 )2 (x − x1 ).
Piecewise-Polynomial Approximation
The simplest piecewise-polynomial approximation is piecewise-linear interpolation, which
consists of joining a set of data points
1
The proofs of the theorems in this section rely on results in Chapter 6.
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
3.5 Cubic Spline Interpolation 145
Figure 3.7
y f (x)
Isaac Jacob Schoenberg To determine the appropriate Hermite cubic polynomial on a given interval is simply
(1903–1990) developed his work a matter of computing H3 (x) for that interval. The Lagrange interpolating polynomials
on splines during World War II needed to determine H3 are of first degree, so this can be accomplished without great
while on leave from the difficulty. However, to use Hermite piecewise polynomials for general interpolation, we
University of Pennsylvania to need to know the derivative of the function being approximated, and this is frequently
work at the Army’s Ballistic
unavailable.
Research Laboratory in
The remainder of this section considers approximation using piecewise polynomials
Aberdeen, Maryland. His original
work involved numerical
that require no specific derivative information, except perhaps at the endpoints of the interval
procedures for solving on which the function is being approximated.
differential equations. The much The simplest type of differentiable piecewise-polynomial function on an entire interval
broader application of splines to [x0 , xn ] is the function obtained by fitting one quadratic polynomial between each successive
the areas of data fitting and pair of nodes. This is done by constructing a quadratic on [x0 , x1 ] agreeing with the function
computer-aided geometric design at x0 and x1 , another quadratic on [x1 , x2 ] agreeing with the function at x1 and x2 , and so
became evident with the on. A general quadratic polynomial has three arbitrary constants—the constant term, the
widespread availability of coefficient of x, and the coefficient of x 2 —and only two conditions are required to fit the
computers in the 1960s.
data at the endpoints of each subinterval. So flexibility exists that permits the quadratics to
be chosen so that the interpolant has a continuous derivative on [x0 , xn ]. The difficulty arises
because we generally need to specify conditions about the derivative of the interpolant at
the endpoints x0 and xn . There is not a sufficient number of constants to ensure that the
conditions will be satisfied. (See Exercise 26.)
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
146 CHAPTER 3 Interpolation and Polynomial Approximation
Figure 3.8
S(x)
S n2
S n1
S1 Sj
S j1
S0
S j (x j1) f (x j1) S j1(x j1)
S j (x j1) Sj1(x j1)
S j(x j1) S j1
(x j1)
Definition 3.10 Given a function f defined on [a, b] and a set of nodes a = x0 < x1 < · · · <
xn = b, a cubic spline interpolant S for f is a function that satisfies the following
conditions:
(a) S(x) is a cubic polynomial, denoted Sj (x), on the subinterval [xj , xj+1 ] for each
A natural spline has no conditions j = 0, 1, . . . , n − 1;
imposed for the direction at its
endpoints, so the curve takes the (b) Sj (xj ) = f (xj ) and Sj (xj+1 ) = f (xj+1 ) for each j = 0, 1, . . . , n − 1;
shape of a straight line after it (c) Sj+1 (xj+1 ) = Sj (xj+1 ) for each j = 0, 1, . . . , n − 2; (Implied by (b).)
passes through the interpolation
points nearest its endpoints. The (d) Sj+1 (xj+1 ) = Sj (xj+1 ) for each j = 0, 1, . . . , n − 2;
name derives from the fact that (e) Sj+1 (xj+1 ) = Sj (xj+1 ) for each j = 0, 1, . . . , n − 2;
this is the natural shape a flexible
strip assumes if forced to pass (f) One of the following sets of boundary conditions is satisfied:
through specified interpolation
points with no additional
(i) S (x0 ) = S (xn ) = 0 (natural (or free) boundary);
constraints. (See Figure 3.9.) (ii) S (x0 ) = f (x0 ) and S (xn ) = f (xn ) (clamped boundary).
Although cubic splines are defined with other boundary conditions, the conditions given
in (f) are sufficient for our purposes. When the free boundary conditions occur, the spline is
called a natural spline, and its graph approximates the shape that a long flexible rod would
Figure 3.9 assume if forced to go through the data points {(x0 , f (x0 )), (x1 , f (x1 )), . . . , (xn , f (xn ))}.
In general, clamped boundary conditions lead to more accurate approximations because
they include more information about the function. However, for this type of boundary
condition to hold, it is necessary to have either the values of the derivative at the endpoints
or an accurate approximation to those values.
Example 1 Construct a natural cubic spline that passes through the points (1, 2), (2, 3), and (3, 5).
Solution This spline consists of two cubics. The first for the interval [1, 2], denoted
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
3.5 Cubic Spline Interpolation 147
There are 8 constants to be determined, which requires 8 conditions. Four conditions come
from the fact that the splines must agree with the data at the nodes. Hence
Two more come from the fact that S0 (2) = S1 (2) and S0 (2) = S1 (2). These are
S0 (2) = S1 (2) : b0 + 2c0 + 3d0 = b1 and S0 (2) = S1 (2) : 2c0 + 6d0 = 2c1
Sj (x) = aj + bj (x − xj ) + cj (x − xj )2 + dj (x − xj )3 ,
Clamping a spline indicates that
the ends of the flexible strip are for each j = 0, 1, . . . , n − 1. Since Sj (xj ) = aj = f (xj ), condition (c) can be applied to
fixed so that it is forced to take a
obtain
specific direction at each of its
endpoints. This is important, for
example, when two spline aj+1 = Sj+1 (xj+1 ) = Sj (xj+1 ) = aj + bj (xj+1 − xj ) + cj (xj+1 − xj )2 + dj (xj+1 − xj )3 ,
functions should match at their
endpoints. This is done for each j = 0, 1, . . . , n − 2.
mathematically by specifying the The terms xj+1 − xj are used repeatedly in this development, so it is convenient to
values of the derivative of the introduce the simpler notation
curve at the endpoints of the
spline.
hj = xj+1 − xj ,
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
148 CHAPTER 3 Interpolation and Polynomial Approximation
for each j = 0, 1, . . . , n − 1.
Another relationship between the coefficients of Sj is obtained by defining cn =
S (xn )/2 and applying condition (e). Then, for each j = 0, 1, . . . , n − 1,
Solving for dj in Eq. (3.17) and substituting this value into Eqs. (3.15) and (3.16) gives,
for each j = 0, 1, . . . , n − 1, the new equations
hj2
aj+1 = aj + bj hj + (2cj + cj+1 ) (3.18)
3
and
The final relationship involving the coefficients is obtained by solving the appropriate
equation in the form of equation (3.18), first for bj ,
1 hj
bj = (aj+1 − aj ) − (2cj + cj+1 ), (3.20)
hj 3
and then, with a reduction of the index, for bj−1 . This gives
1 hj−1
bj−1 = (aj − aj−1 ) − (2cj−1 + cj ).
hj−1 3
Substituting these values into the equation derived from Eq. (3.19), with the index reduced
by one, gives the linear system of equations
3 3
hj−1 cj−1 + 2(hj−1 + hj )cj + hj cj+1 = (aj+1 − aj ) − (aj − aj−1 ), (3.21)
hj hj−1
for each j = 1, 2, . . . , n − 1. This system involves only the {cj }nj=0 as unknowns. The values
of {hj }n−1
j=0 and {aj }j=0 are given, respectively, by the spacing of the nodes {xj }j=0 and the
n n
values of f at the nodes. So once the values of {cj }j=0 are determined, it is a simple matter
n
to find the remainder of the constants {bj }n−1 j=0 from Eq. (3.20) and {dj }j=0 from Eq. (3.17).
n−1
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
3.5 Cubic Spline Interpolation 149
Natural Splines
Theorem 3.11 If f is defined at a = x0 < x1 < · · · < xn = b, then f has a unique natural spline interpolant
S on the nodes x0 , x1 , . . ., xn ; that is, a spline interpolant that satisfies the natural boundary
conditions S (a) = 0 and S (b) = 0.
Proof The boundary conditions in this case imply that cn = S (xn )/2 = 0 and that
The matrix A is strictly diagonally dominant, that is, in each row the magnitude of the
diagonal entry exceeds the sum of the magnitudes of all the other entries in the row. A linear
system with a matrix of this form will be shown by Theorem 6.21 in Section 6.6 to have a
unique solution for c0 , c1 , . . . , cn .
The solution to the cubic spline problem with the boundary conditions S (x0 ) =
S (xn ) = 0 can be obtained by applying Algorithm 3.4.
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
150 CHAPTER 3 Interpolation and Polynomial Approximation
Example 2 At the beginning of Chapter 3 we gave some Taylor polynomials to approximate the expo-
nential f (x) = ex . Use the data points (0, 1), (1, e), (2, e2 ), and (3, e3 ) to form a natural
spline S(x) that approximates f (x) = ex .
c0 = 0,
c0 + 4c1 + c2 = 3(e2 − 2e + 1),
c1 + 4c2 + c3 = 3(e3 − 2e2 + e),
c3 = 0.
1 1 3
c1 = (−e3 + 6e2 − 9e + 4) ≈ 0.75685, and c2 = (4e − 9e2 + 6e − 1) ≈ 5.83007.
5 5
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
3.5 Cubic Spline Interpolation 151
Figure 3.10
y
e3
y = S(x)
y = ex
e2
e
1
1 2 3 x
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
152 CHAPTER 3 Interpolation and Polynomial Approximation
The NumericalAnalysis package can be used to create a cubic spline in a manner similar
to other constructions in this chapter. However, the CurveFitting Package in Maple can also
be used, and since this has not been discussed previously we will use it to create the natural
spline in Example 2. First we load the package with the command
with(CurveFitting)
f := x → ex
To create a spline we need to specify the nodes, variable, the degree, and the natural end-
points. This is done with
Maple returns
sn(t)
which produces
⎧
⎪
⎨1. + 1.465998t + 0.2522848t
2 3
t < 1.0
0.495432 + 2.22285t + 0.756853(t − 1.0)2 + 1.691071(t − 1.0)3 t < 2.0
⎪
⎩
−10.230483 + 8.809770t + 5.830067(t − 2.0)2 − 1.943356(t − 2.0)3 otherwise
Illustration To approximate the integral of f (x) = ex on [0, 3], which has the value
3
ex dx = e3 − 1 ≈ 20.08553692 − 1 = 19.08553692,
0
we can piecewise integrate the spline that approximates f on this integral. This gives
3 1
S(x) = 1 + 1.46600x + 0.25228x 3 dx
0 0
2
+ 2.71828 + 2.22285(x − 1) + 0.75685(x − 1)2 + 1.69107(x − 1)3 dx
1
3
+ 7.38906 + 8.80977(x − 2) + 5.83007(x − 2)2 − 1.94336(x − 2)3 dx.
2
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
3.5 Cubic Spline Interpolation 153
Because the nodes are equally spaced in this example the integral approximation is
simply
3
1 1 1
S(x) dx = (a0 +a1 +a2 )+ (b0 +b1 +b2 )+ (c0 +c1 +c2 )+ (d0 +d1 +d2 ). (3.22)
0 2 3 4
If we create the natural spline using Maple as described after Example 2, we can then
use Maple’s integration command to find the value in the Illustration. Simply enter
int(sn(t), t = 0 .. 3)
19.55228648
Clamped Splines
Example 3 In Example 1 we found a natural spline S that passes through the points (1, 2), (2, 3),
and (3, 5). Construct a clamped spline s through these points that has s (1) = 2 and
s (3) = 1.
Solution Let
Then most of the conditions to determine the 8 constants are the same as those in Example
1. That is,
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.