0% found this document useful (0 votes)
116 views5 pages

Homework 4 Solutions

The document provides solutions to homework problems involving Hermite interpolation and numerical differentiation. For problem 1, it proves an error formula for Hermite interpolation. Problem 2 gives examples of Hermite interpolation polynomials. Problem 3 uses Neville's method to find polynomial approximations from a dataset. Problem 4 discusses error analysis for numerical differentiation formulas.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
116 views5 pages

Homework 4 Solutions

The document provides solutions to homework problems involving Hermite interpolation and numerical differentiation. For problem 1, it proves an error formula for Hermite interpolation. Problem 2 gives examples of Hermite interpolation polynomials. Problem 3 uses Neville's method to find polynomial approximations from a dataset. Problem 4 discusses error analysis for numerical differentiation formulas.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Math 128A: 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].

Observe first that (1) is trivially true if x = xi for 0 ≤ i ≤ n as H agrees with f on


these points. Suppose now that x 6= xi for any i. Define the function
Πnj=0 (t − xj )2
g(t) = f (t) − H(t) − (f (x) − H(x)) .
Πnj=0 (x − xj )2
Observe that for any i,
Πnj=0 (xi − xj )2
g(xi ) = f (xi ) − H(xi ) −(f (x) − H(x)) n =0
| {z } Πj=0 (x − xj )2
0 | {z }
0

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 .

(b) f (x) = x|x| with respect to x0 = −3, x1 = 0 and x2 = 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

3. Consider the following dataset.

xi 0.45 0.5525 0.8225 1.285 1.755


f (xi ) −0.175155 −0.157725 −0.0737543 0.130069 0.326422

(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)

Generally speaking, if we wish to find the best degree n approximation at a


point x, we should use the n + 1 points from the dataset that are closest to x.
Rearranging the points in the order of their distances from x yields

yi 1.285 0.8225 1.7550 0.5525 0.4500


f (yi ) 0.130069 −0.0737543 0.326422 −0.157725 −0.175155

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

Q(1, 1) = 0.0848973, Q(2, 2) = 0.0858046, Q(3, 3) = 0.0822621, Q(4, 4) = 0.0830110

(b) Find the general interpolating polynomial of degree four for f in the Newton form.

We can use the MATLAB function FiniteDiff.m to compute the polynomial.


Using
xvals = [0.45 0.5525 0.8225 1.285 1.755]
fvals = [-0.175155 -0.157725 -0.0737543 0.130069 0.326422 ]

3
as inputs for the function produces the divided difference table, the diagonal of
which has the required coefficients. The interpolating polynomial is

P (x) = −0.175155 + 0.170049(x − 0.45) + 0.378399(x − 0.45)(x − 0.5525) −


0.241125(x − 0.45)(x − 0.5525)(x − 0.8225) +
0.0562728(x − 0.45)(x − 0.5525)(x − 0.8225)(x − 1.285).

4. Consider the differentiation formulae

(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.

We shall take  = 2.220446049250313 × 10−16 .


(i) Observe that f (2) (x) = − sin(x) ⇒ |f (2) (x)| ≤ 1 so M = 1. The optimal h is
therefore  1/3
6
h= = 1.1003 × 10−5 .
1
The corresponding approximation to f 0 (x0 ) is

−3 sin(π/6) + 4 sin(π/6 + h) − sin(π/6 + 2h)


= 0.866025403824350 .
2h

Compared to the actual answer 3/2, this is accurate to 3.99117 × 10−11 .
(ii) Observe that f (3) (x) = − cos(x) ⇒ |f (3) (x)| ≤ 1 so M = 1. The optimal h is
therefore  1/4
48
h= = 1.1003 × 10−5 .
1
The corresponding approximation to f 0 (x0 ) is

sin(π/6 − h) − 2 sin(π/6) + sin(π/6 + h)


= −0.499999996402878 .
h2
Compared to the actual answer −1/2, this is accurate to 3.5971 × 10−9 .

You might also like