Docsity

Final Exam Solutions - Numerical Analysis | MATH 128A, Exams of Mathematical Methods for Numerical Analysis and Optimization

Toggle sidebar
bg1
UCB MATH 128A-2, SUMMER 2009: FINAL EXAM SOLUTIONS
JUSTIN BLANCHARD
1. (a) Prove that the bisection method on [1,2] will converge to a root of x3−x−1.
(b) Find a bound on the absolute error in approximating this root after niterations.
(c) How many iterations are necessary to ensure the relative error is at most 2−5?
(Your answer does not have to be exact.)
Solution:
(a) This function is continuous. Its values at the endpoints are −1<0 and 5 >0. Therefore, the
interval brackets a root and the bisection method will converge.
(b) On the nth iteration, the root is known to lie in an interval of width 2−1
2n−1. Its distance from this
interval’s midpoint can be at most 1/2n. (The answer 1/2n+1 is also acceptable, depending
on how the phrase “after niterations” is interpreted.)
(c) Since the root lies in [1,2], the relative error is at most equal to the absolute error. By (b), we
must use n= 5 iterations.
2. (a) Find an algebraic expression for the unique root (in R) of f(x) = x2−2/x.
(b) Newton’s method searches for this root using the iteration pn+1 =g(pn).
Find g(x). Simplify your answer.
(c) Is the convergence linear? Is it at least quadratic?
(d) Find the exact order of convergence.
Solution:
(a) x2−2/x = 0 ⇐⇒ x3−2=0 ⇐⇒ x= 21/3.
(b) g(x) = x−f(x)
f0(x)=x−x2−2/x
2x+2/x2=x−xx3−2
2x3+2 =x(x3+ 4)
2(x3+ 1)
(c) The convergence is at least quadratic, for either of the following reasons: 21/3is a simple root
of f(x), as f0(21/3)=2·21/3+ 2/22/36= 0. Alternatively, g0(21/3) = 0 after the calculation
g0(x) = (4x3+4)2(x3+1)−x(x3+4)(6x2)
22(x3+1)2=8(x3+1)2−6x3(x3+4)
22(x3+1)2.
(d) (This was intended to be a harder problem.)
By definition, the order of convergence is αiff limn→∞
pn+1−21/3
pn−21/3=λ6= 0. If pn=x, this
fraction’s numerator is g(x)−21/3=x4−24/3x3+4x−2
2(x3+1) . Factor out (x−21/3) as many times
as possible: (x−21/3)3(x+21/3)
2(x3+1) . (Alternatively, Taylor-expand x4−24/3x3+ 4x−2 with center
x= 21/3.) It follows that the order of convergence is 3
3. (a) Estimate y(1/2) with polynomial interpolation given the data y(0) = 1, y(1) = 2.
(b) Repeat part (a) with Hermite interpolation, if y(t) is a solution to y0=y.
Solution:
(a) Polynomial interpolation in this case is linear interpolation, so y(0.5) ≈1.5
(b) Hermite interpolation, Newton form:
Date: Thursday 8/13.
1
pf3
pf4

Partial preview of the text

Download Final Exam Solutions - Numerical Analysis | MATH 128A and more Exams Mathematical Methods for Numerical Analysis and Optimization in PDF only on Docsity!

UCB MATH 128A-2, SUMMER 2009: FINAL EXAM SOLUTIONS

JUSTIN BLANCHARD

  1. (a) Prove that the bisection method on [1, 2] will converge to a root of x^3 − x − 1. (b) Find a bound on the absolute error in approximating this root after n iterations. (c) How many iterations are necessary to ensure the relative error is at most 2−^5? (Your answer does not have to be exact.) Solution: (a) This function is continuous. Its values at the endpoints are − 1 < 0 and 5 > 0. Therefore, the interval brackets a root and the bisection method will converge. (b) On the nth iteration, the root is known to lie in an interval of width (^22) n−−^11. Its distance from this interval’s midpoint can be at most 1 / 2 n^. (The answer 1/ 2 n+1^ is also acceptable, depending on how the phrase “after n iterations” is interpreted.) (c) Since the root lies in [1, 2], the relative error is at most equal to the absolute error. By (b), we must use n = 5 iterations.
  2. (a) Find an algebraic expression for the unique root (in R) of f (x) = x^2 − 2 /x. (b) Newton’s method searches for this root using the iteration pn+1 = g(pn). Find g(x). Simplify your answer. (c) Is the convergence linear? Is it at least quadratic? (d) Find the exact order of convergence. Solution: (a) x^2 − 2 /x = 0 ⇐⇒ x^3 − 2 = 0 ⇐⇒ x = 2^1 /^3.

(b) g(x) = x − (^) ff ′^ ((xx)) = x − x

(^2) − 2 /x 2 x+2/x^2 =^ x^ −^ x^

x^3 − 2 2 x^3 +2 =^

x(x^3 + 4) 2(x^3 + 1) (c) The convergence is at least quadratic, for either of the following reasons: 2^1 /^3 is a simple root of f (x), as f ′(2^1 /^3 ) = 2 · 21 /^3 + 2/ 22 /^3 6 = 0. Alternatively, g′(2^1 /^3 ) = 0 after the calculation g′(x) = (4x

(^3) +4)2(x (^3) +1)−x(x (^3) +4)(6x (^2) ) 22 (x^3 +1)^2 =^

8(x^3 +1)^2 − 6 x^3 (x^3 +4) 22 (x^3 +1)^2. (d) (This was intended to be a harder problem.) By definition, the order of convergence is α iff limn→∞

pn+1− 21 /^3 pn− 21 /^3

∣ =^ λ^6 = 0.^ If^ pn =^ x, this fraction’s numerator is g(x) − 21 /^3 = x

(^4) − 24 / (^3) x (^3) +4x− 2 2(x^3 +1).^ Factor out (x^ −^2

1 / (^3) ) as many times

as possible: (x−^2

1 / (^3) ) (^3) (x+2 1 / (^3) ) 2(x^3 +1). (Alternatively, Taylor-expand^ x

(^4) − 24 / (^3) x (^3) + 4x − 2 with center

x = 2^1 /^3 .) It follows that the order of convergence is 3

  1. (a) Estimate y(1/2) with polynomial interpolation given the data y(0) = 1, y(1) = 2. (b) Repeat part (a) with Hermite interpolation, if y(t) is a solution to y′^ = y. Solution: (a) Polynomial interpolation in this case is linear interpolation, so y(0.5) ≈ 1. 5 (b) Hermite interpolation, Newton form:

Date: Thursday 8/13. 1

x 0 = 0 f [x 0 ] = 1 f [x 0 , x 1 ] = 1 x 1 = 0 f [x 1 ] = 1 f [x 0 , x 1 , x 2 ] = 0 f [x 1 , x 2 ] = 1 f [x 0 , x 1 , x 2 , x 3 ] = 1 x 2 = 1 f [x 2 ] = 2 f [x 0 , x 1 , x 2 ] = 1 f [x 2 , x 3 ] = 2 x 3 = 1 f [x 3 ] = 2

Using the co-

efficients above, we can read off the polynomial P (x) = 1+1(x−0)+0(x−0)^2 +1(x−0)^2 (x−1) = 1 + x − x^2 + x^3. Plugging in x = 0.5 yields 1. 375

  1. (a) Transform

− 3

1 t^2 +1 dt^ to an integral of the form^

− 1 f^ (x)^ dx. (b) Find the coefficients below for the three-point Gaussian quadrature rule: ∫ (^1)

− 1

f (x) dx ≈ af

  • bf (0) + cf

(c) What is this rule’s degree of precision? (d) Estimate the integral from (a) using this rule. Express your answer as a fraction. Solution:

(a) Let t = 3x to get

− 1

9 x^2 + 1 dx

(b) Method one:

f (x) = x^0 :

− 1

x^0 dx =

= +a

  • b + c

=⇒ a + b + c = 2

f (x) = x^1 :

− 1

x^1 dx =0 = −a

  • c

=⇒ a = c

f (x) = x^2 :

− 1

x^2 dx =

= +a

  • c

=⇒ a = c =

=⇒ b =

Method two: Integrate Lagrange polynomials: for instance, a =

− 1

(x−0)(x−

3 /5) (−

3 / 5 −0)(−

3 / 5 −

3 /5) dx, etc. (This strategy leads to a mess, and will not be elaborated here.) (c) Method one: It’s 5 because Gaussian quadrature achieves degree of precision 2(# nodes) − 1. Method two: Continue the tests above. The first one that fails is f (x) = x^6 , so the degree is 5.

(d) (^59) 9(3/^3 5)+1 + 89 (3) + (^59) 9(3/^3 5)+1 = (^92) · 32 ·^5 ·/^35 + 89 ·^3 = (^325) · 16 + 83 = 15348 =

  1. (a) Find the local truncation error for the method wi+1 = 4wi − 3 wi− 1 − 2 hf (ti− 1 , wi− 1 ). (b) Classify this multistep method as strongly stable, weakly stable, or unstable. Solution: (a) Note: This may be clearer if written out, long-hand. Let y(t) =

cn(t − ti)n. Then y′(t) =

ncn(t − ti)n−^1 , and

τi+1 =

y(ti + h) − wi+ h

= − 4 c 0 h−^1 +

cn[1 + 3(−1)n^ + 2n(−1)n−^1 ]hn−^1 = 0 + 0 + 0 + 4c 3 h^2 +...

Thus, the local truncation error is O(h^2 ) (b) The characteristic polynomial for this method is λ^2 − 4 λ + 3 = (λ − 3)(λ − 1). Since | 3 | > 1, the method is unstable.

Find a Cholesky (LL∗) factorization for this matrix: A =

Solution: If you remember (or re-derive, as described in class) a Cholesky factorization algorithm, you can practically write down the answer. If not, there is still hope: A = LL∗^ must take the form    

a 0 0 0 b c 0 0 d e f 0 g h i j

a b d g 0 c e h 0 0 f i 0 0 0 j

a^2 ab ad ag ???? ???? ????

Without further computation, you can find a = 1, b = 0, d = 1, g = 1, and write    

0 c 0 0 1 e f 0 1 h i j

0 c e h 0 0 f i 0 0 0 j

0 c^2 ce ch ???? ????

Write down c = 1, e = 0, h = 2, and    

1 0 f 0 1 2 i j

0 0 f i 0 0 0 j

1 0 1 + f 2 1 + f i ????

Write down f = 1, i = 0, and    

1 2 0 j

0 0 0 j

1 2 1 5 + j^2

Finally, j = 1, and the desired factorization has

L =