Docsity

Practice Midterm Exam Solutions - Numerical Analysis | Math 105, Exams of Mathematical Methods for Numerical Analysis and Optimization

Toggle sidebar
bg1
Jim Lambers
Math 105A
Summer Session I 2003-04
Practice Midterm Exam Solution
1. Let f(x) = sin 2x+ cos 2x.
(a) Write down the 2nd Taylor polynomial P2(x) of f(x) centered around x0= 0.
Solution We have
f0(x) = 2 cos 2x−2 sin 2x, f00(x) = −4 sin 2x−4 cos 2x.
Therefore,
f(0) = 1, f0(0) = 2, f00(0) = −4.
Using Taylor’s Theorem, we obtain
P2(x) = f(x0) + f0(x0)(x−x0) + 1
2f00(x0)(x−x0)2
=f(0) + f0(0)x+1
2f00(0)x2
= 1 + 2x−1
24x2
= 1 + 2x−2x2.
(b) Write down the corresponding Taylor remainder R2(x).
Solution In general, we have
R2(x) = f(3)(ξ(x))
3! (x−x0)3,
where ξ(x) is between x0and x. Since
f000(x) = −8 cos 2x+ 8 sin 2x,
it follows that
R2(x) = −8 cos 2ξ(x) + 8 sin2ξ(x)
6x3.
(c) Suppose P2(x) is used to approximate f(x) on the interval [−π, π]. How large in mag-
nitude can the absolute error in this approximation be?
Solution A crude, but acceptable, bound for f(3)(x) on this interval is
| − 8 cos 2x+ 8 sin 2x| ≤ 8|cos 2x|+ 8|sin 2x| ≤ 16.
1
pf3
pf4
pf5

Partial preview of the text

Download Practice Midterm Exam Solutions - Numerical Analysis | Math 105 and more Exams Mathematical Methods for Numerical Analysis and Optimization in PDF only on Docsity!

Jim Lambers Math 105A

Summer Session I 2003-

Practice Midterm Exam Solution

  1. Let f (x) = sin 2x + cos 2x.

(a) Write down the 2nd Taylor polynomial P 2 (x) of f (x) centered around x 0 = 0.

Solution We have

f

′ (x) = 2 cos 2x − 2 sin 2x, f

′′ (x) = −4 sin 2x − 4 cos 2x.

Therefore, f (0) = 1, f ′(0) = 2, f ′′(0) = − 4.

Using Taylor’s Theorem, we obtain

P 2 (x) = f (x 0 ) + f ′(x 0 )(x − x 0 ) +

f ′′(x 0 )(x − x 0 )^2

= f (0) + f ′(0)x +

f ′′(0)x^2

= 1 + 2x −

4 x

2

= 1 + 2x − 2 x

2 .

(b) Write down the corresponding Taylor remainder R 2 (x).

Solution In general, we have

R 2 (x) =

f (3)(ξ(x))

3!

(x − x 0 )^3 ,

where ξ(x) is between x 0 and x. Since

f

′′′ (x) = −8 cos 2x + 8 sin 2x,

it follows that

R 2 (x) =

−8 cos 2ξ(x) + 8 sin 2ξ(x)

6

x^3.

(c) Suppose P 2 (x) is used to approximate f (x) on the interval [−π, π]. How large in mag-

nitude can the absolute error in this approximation be?

Solution A crude, but acceptable, bound for f (3)(x) on this interval is

| − 8 cos 2x + 8 sin 2x| ≤ 8 | cos 2x| + 8| sin 2x| ≤ 16.

A sharper bound could be obtained by computing the maximum value of f (3)(x) on [−π, π] but this is not necessary. We conclude that on this interval,

|R 2 (x)| ≤

16 π^3

6

  1. Consider the expression (^) √

6 + h −

h

which is to be evaluated for some small positive constant h.

(a) Compute the value of this expression with h = 0.0001 using five decimal digits of preci- sion and chopping. Given that the exact value, to eight decimal places, is 0.20412329,

explain why your computed value is so inaccurate.

Solution Using five-digit chopping, we obtain

√ 6 + h −

h

The reason this result is so inaccurate is the catastrophic cancellation that occurs in the numerator, subtracting two numbers that are so close to each other, relative to the given

precision, that their difference cannot be represented accurately.

(b) Rewrite the expression and repeat the computation, again with five-digit chopping arith- metic.

Solution Multiplying and dividing by the conjugate

6 + h +

6, we obtain √ 6 + h −

h

6 + h −

h

6 + h +

6 + h +

6 + h)^2 − (

6)^2

h(

6 + h +

6 + h − 6

h(

6 + h +

h

h(

6 + h +

6 + h +

h^2

6

e +

h^3

24

[

e

6

]

h

2 ,

since the maximum value of eh^ on [− 1 , 1] is e^1 = e, and the maximum value of cos h on the same interval is cos 0 = 1. We conclude that f (h) converges to 1 with rate of convergence

O(h^2 ).

  1. Given

f (x) = 9x

2 − 1 ,

use the bisection method to compute a solution of f (x) = 0 that is accurate to within 1/16, given that a solution lies within the interval [0, 1 /2].

Solution First, we compute f (0) = −1 and f (1/2) = 9/ 4 − 1 = 5/4. Then, we compute the

midpoint of the interval [0, 1 /2] and obtain m = (0+1/2)/2 = 1/4. Since f (1/4) = 9/ 16 −1 = 7 / 16 < 0, and f (1/2) > 0, there is a solution in the interval (1/ 4 , 1 /2).

At the midpoint m = (1/4 + 1/2)/2 = 3/8, we have f (3/8) = 81/ 64 − 1 = 17/ 64 > 0,

and since f (1/4) < 0, there is a solution in the interval (1/ 4 , 3 /8). At the midpoint of this

interval m = (1/4 + 3/8)/2 = 5/16, we have f (5/16) = 225/ 256 − 1 = − 31 / 256 < 0, and since f (3/8) > 0, there is a solution in the interval (5/ 16 , 3 /8), or (5/ 16 , 6 /16).

This interval has a width of 1/16, so any number in this interval can be chosen for an

approximate solution and it would be accurate to within 1/16.

  1. Given

g(x) = e

x/ 4

(a) Show that g(x) has a unique fixed point in the interval [1, 2].

Solution In general, a function g(x) has a unique fixed point on [a, b] if

  • g is continuous on [a, b]. Since g is an exponential of a continuous function, it is

continuous.

  • g(x) ∈ [a, b] whenever x ∈ [a, b]. We have g′(x) = (1/4)ex/^4 , and since ex/^4 > 0 for

all x, it follows that g(x) is always increasing. Therefore, g(x) assumes its maximum

value on [1, 2] at x = 2 and its minimum value at x = 1. Since the maximum value is g(2) = e^1 /^2 ≈ 1 .6487 and the minimum value is g(1) = e^1 /^4 ≈ 1 .2840. We conclude

that g(x) ∈ [1, 2] whenever x ∈ [1, 2].

  • |g′(x)| ≤ k on [a, b], where k < 1. Using the same logic as above, we can see that

g′(x) is always increasing. Therefore, it assumes its minimum value on [0, 1] at g′(1) ≈ 0 .3210, and its maximum value at g′(2) ≈ 0 .4122. We conclude that |g′(x)|

is bounded away from 1 on [1, 2].

Since g(x) satisfies all three conditions on [1, 2], it has a unique fixed point on this interval.

(b) Perform three iterations of Fixed-point Iteration with x 0 = 1.5 to find an approximation

to the fixed point.

Solution In six-digit rounding arithmetic, we have

x 1 = ex^0 /^4 = e^1.^5 /^4 = 1. 45499

x 2 = e

x 1 / 4 = e

  1. 45499 / 4 = 1. 43871

x 3 = ex^2 /^4 = e^1.^43871 /^4 = 1. 43287.

  1. Perform three iterations of Newton’s Method to solve the equation f (x) = 0, where

f (x) = x

3 − 3 x

2

Use x 0 = 1. 9. Given that the exact root is x∗^ = 2, do the iterations appear to be converging

quadratically? If so, explain why. If not, explain why not.

Solution Using Newton’s Method,

xn+1 = xn −

f (xn)

f ′(xn)

we have the iteration

xn+1 = xn −

x^3 n − 3 x^2 n + 4

3 x^2 n − 6 xn

which yields, in seven-digit rounding arithmetic,

x 1 = 1. 9 −

x 2 = 1. 950877 −

x 3 = 1. 975645 −

(1. 9319 − 1 .7321)^2

xˆ 2 = x 2 −

(x 3 − x 2 )^2

x 4 − 2 x 3 + x 2

(1. 9829 − 1 .9319)^2