Homework 4 Solutions
Homework 4 Solutions
Due: July 12
1. Suppose f ∈ C 2n+2 ([a, b]) and x0 , x1 , . . . , xn are distinct points in [a, b]. Let H(x) be
the Hermite interpolating polynomial for f with respect to these points. Prove that
for all x ∈ [a, b], there exists c(x) ∈ (a, b) such that
f (2n+2) (c(x)) n
f (x) − H(x) = Πi=0 (x − xi )2 . (1)
(2n + 2)!
Hint: use the same method as in the Lagrange polynomial error estimate on the
function
Πn (t − xi )2
g(t) = f (t) − H(t) − (f (x) − H(x)) ni=0
Πi=0 (x − xi )2
along with the fact that g 0 has distinct 2n + 2 zeros in [a, b].
as well as
Πnj=0 (x − xj )2
g(x) = f (x) − H(x) − (f (x) − H(x)) n = f (x) − H(x) − (f (x) − H(x)) = 0.
Πj=0 (x − xj )2
It follows that g has n + 2 distinct zeros at x, x0 , x1 , . . . , xn . Applying Rolle’s theorem
on the n+1 consecutive pairs, we infer that g 0 has at least (n+1) zeros bk for 0 ≤ k ≤ n,
none of which are x, x0 , x1 , . . . , xn .
In addition, observe that the expression r(t) := Πnj=0 (t − xj )2 has zeros of multiplicity
2 at all the xi ’s. This implies that r0 (xi ) = 0 for all xi . Thus,
r0 (t)
g 0 (t) = f 0 (t) − H 0 (t) − (f (x) − H(x))
Πnj=0 (x − xj )2
r0 (xi )
g 0 (xi ) = f 0 (xi ) − H 0 (xi ) −(f (x) − H(x)) n =0
| {z } Πj=0 (x − xj )2
0
1
where we used r0 (xi ) = 0. We have therefore shown that g 0 has 2n + 2 distinct zeros:
the xi ’s and the bk ’s.
The Generalized Rolle’s theorem then implies that for some c(x) ∈ (a, b), we have
(g 0 )(2n+1) (c(x)) = 0 ⇔ g (2n+2) (c(x)) = 0. Note that as the degree of r(t) is 2n + 2, we
have r(2n+2) (t) = (2n + 2)!. Meanwhile, the degree of H is 2n + 1 so H (2n+2) (t) = 0.
Thus,
r(2n+2) (c(x))
g (2n+2) (c(x)) = f (2n+2) (c(x)) − H (2n+2) (c(x)) − (f (x) − H(x))
Πnj=0 (x − xj )2
(2n + 2)!
0 = f (2n+2) (c(x)) − (f (x) − H(x))
Πnj=0 (x− xj )2
f (2n+2) (c(x)) n
f (x) − H(x) = Πj=0 (x − xj )2 .
(2n + 2)!
2. Find the Hermite interpolating polynomial for the following functions with respect to
the given points.
2
(a) f (x) = e−x with respect to x0 = −1, x1 = 0 and x2 = 1.
2
Observe that f (−1) = f (1) = e−1 and f (0) = 1 while f 0 (x) = −2xe−x ⇒
f 0 (−1) = 2e−1 , f (0) = 0, f (1) = −2e−1 .
We use the divided differences method to compute the Hermite polynomial. We
have
z0 = −1 e−1
2e−1
z1 = −1 e−1 1 − 3e−1
1 − e−1 4e−1 − 2
−1
z2 = 0 1 e −1 1 − 2e−1
0 0 0
z3 = 0 1 e−1 − 1 1 − 2e−1
e−1 − 1 2 − 4e−1
z4 = 1 e−1 1 − 3e−1
−1
−2e
−1
z5 = 1 e
It follows that the required polynomial is
H(x) = e−1 + 2e−1 (x + 1) + (1 − 3e−1 )(x + 1)2 + (4e−1 − 2)x(x + 1)2 +
(1 − 2e−1 )x2 (x + 1)2 .
We have f (−3) = −9, f (0) = 0 and f (2) = 4. Note further that f is differentiable
everywhere and that f 0 (x) = 2|x| so that f 0 (−3) = 6, f 0 (0) = 0, f 0 (2) = 4. We
then have
2
z0 = −3 −9
6
z1 = −3 −9 −1
3 0
z2 = 0 0 −1 2/25
0 2/5 −4/125
z3 = 0 0 1 −2/25
2 0
z4 = 2 4 1
4
z5 = 2 4
The required polynomial then is
2 2 4 2
H(x) = −9 + 6(x + 3) − (x + 3)2 + x (x + 3)2 − x (x − 2)(x + 3)2
25 125
(a) Use Neville’s method to find the best degree one, two, three and four approxima-
tions to f (1.1825). (Hint: you may have to rearrange the order of the points)
Using the MATLAB code nevilemethod.m, we can find the best degree n approx-
imations to f (1.1825), n = 1, . . . , 4, by considering the entries on the diagonal of
the matrix Q. We get
(b) Find the general interpolating polynomial of degree four for f in the Newton form.
3
as inputs for the function produces the divided difference table, the diagonal of
which has the required coefficients. The interpolating polynomial is
(i)
−3f (x0 ) + 4f (x0 + h) − f (x0 + 2h) h2 (3)
f 0 (x0 ) = + f (c(x0 ))
2h 3
(ii)
f (x0 − h) − 2f (x0 ) + f (x0 + h) h2 (4)
f 00 (x0 ) = − f (ĉ(x0 )).
h2 12
For both (i) and (ii)
(a) find the optimal h > 0 that minimizes the error bound in the derivative ap-
proximation. You may assume that the appropriate higher derivatives of f are
bounded.
Suppose that the value f (x) is actually recorded as fˆ(x) during computations
with
f (x) = fˆ(x) + e(x)
where e(x) is the round-off error; we can safely assume that |e(x)| ≤ , the machine
epsilon.
(i) The total error is given by
!
−3 fˆ(x 0 ) + 4 ˆ
f (x 0 + h) − ˆ
f (x 0 + 2h)
E = f 0 (x0 ) −
2h
−3e(x0 ) + 4e(x0 + h) − e(x0 + 2h) h2 (3)
= + f (c(x0 ))
2h 3
3|e(x0 )| + 4|e(x0 + h)| + |e(x0 + 2h)| h2 (3)
≤ + |f (c(x0 ))|
2h 3
3 + 4 + M h2
≤ +
2h 3
4 M h2
where M is an upper bound for |f (3) (x)|. Let g(h) = h
+ 3
; then
1/3
0 4 2M h 6
g (h) = − 2 + =0⇒ h= .
h 3 M
4
(ii) The total error is given by
!
00 ˆ ˆ ˆ
f (x0 − h) − 2f (x0 ) + f (x0 + h)
E = f (x0 ) −
h2
e(x0 − h) − 2e(x0 ) + e(x0 + h) h2 (4)
= − f (ĉ(x 0 ))
h2 12
|e(x0 − h)| + 2|e(x0 )| + |e(x0 + h)| h2 (4)
≤ + |f (ĉ(x0 ))|
h2 12
+ 2 + M h2
≤ +
h2 12
4 M h2
where M is an upper bound for |f (4) (x)|. Let g(h) = h2
+ 12
; then
1/4
0 8 2M h 48
g (h) = − 3 + =0⇒ h= .
h 12 M
(b) For the optimal value of h, find the actual error for f (x) = sin(x) at x0 = π/6.