Docsity

Numerical Analysis Midterm II: Solutions for Prof. Ming Gu's Math128A - Prof. M. Gu, Exams of Mathematical Methods for Numerical Analysis and Optimization

Toggle sidebar
bg1
Prof. Ming Gu, 861 Evans, tel: 2-3145
http://www.math.berkeley.edu/โˆผmgu/MA128A2008S/
Math128A: Numerical Analysis Sample
Midterm II
This is a closed book, closed notes exam. You need to justify every one of your
answers. Completely correct answers given without justification will receive little
credit. Do as much as you can. Partial solutions will get partial credit. Look over
the whole exam to find problems that you can do quickly. You need not simplify your
answers unless you are specifically asked to do so.
Problem Maximum Score Your Score
1 4
2 24
3 24
4 24
5 24
Total 100
1. (10 Points)
Your Name:
Your SID:
Your GSI:
pf3
pf4
pf5
pf8

Partial preview of the text

Download Numerical Analysis Midterm II: Solutions for Prof. Ming Gu's Math128A - Prof. M. Gu and more Exams Mathematical Methods for Numerical Analysis and Optimization in PDF only on Docsity!

Prof. Ming Gu, 861 Evans, tel: 2- Email: [email protected] http://www.math.berkeley.edu/โˆผmgu/MA128A2008S/

Math128A: Numerical Analysis Sample

Midterm II

This is a closed book, closed notes exam. You need to justify every one of your answers. Completely correct answers given without justification will receive little credit. Do as much as you can. Partial solutions will get partial credit. Look over the whole exam to find problems that you can do quickly. You need not simplify your answers unless you are specifically asked to do so.

Problem Maximum Score Your Score

Total 100

  1. (10 Points)

Your Name:

Your SID:

Your GSI:

Math128A: Numerical Analysis Sample Midterm II 2

  1. Booleโ€™s Rule for numerical integration on the interval [a, b] is given by

I 4 (x) =

2 h 45

(7f (a) + 32f (a + h) + 12f (a + 2h) + 32f (a + 3h) + 7f (b)).

(a) Show that the degree of precision of this formula is 5. (b) Develop the Composite Booleโ€™s Rule for integration on [a, b].

Math128A: Numerical Analysis Sample Midterm II 4

  1. Suppose that L = lim hโ†’ 0 f (h) and L โˆ’ f (h) = c 6 h^6 + c 9 h^9 + ยท ยท ยท.

Find a combination of f (h) and f (h/2) that is a much better estimate of L.

Math128A: Numerical Analysis Sample Midterm II 5

  1. Given h = 0.1, f (0) = 0, f (0.1) = 0.01 and f (0.2) = 0.04, find a second order approximation to f โ€ฒ(0).

(3) f (x) = sin(x)/x. We approximate by natural spline at x = โˆ’ 1 , 0 , 1. f (โˆ’1) = sin(โˆ’1)/(โˆ’1) = sin(1), f (1) = sin(1)/1 = sin(1). To find f (0) we take the limit limxโ†’ 0 sin(x)/x = cos(0)/1 = 1 by Lโ€™Hopitalโ€™s rule. So our points are f (โˆ’1) = f (1) = sin(1), f (0) = 1. Now we find the natural spline P. We have eight variables: on [โˆ’ 1 , 0] we have P (x) = a(x + 1)^3 + b(x + 1)^2 + c(x + 1) + d, while on [0, 1] we have P (x) = qx^3 + rx^2 + sx + t. Since the spline must match the value of f at the given points, we have P (โˆ’1) = d = sin(1), P (0) = a+b+c+d = t = 1, P (1) = q+r+s+t = sin(1). P โ€ฒ(x) is 3a(x + 1)^2 + 2b(x + 1) + c on [โˆ’ 1 , 0] and 3qx^2 + 2rx + s on [0, 1]. For the first derivative to be continuous at 0, we must have 3a + 2b + c = s. P โ€ฒโ€ฒ(x) is 6a(x + 1) + 2b on [โˆ’ 1 , 0] and 6qx + 2r on [0, 1]. For the second derivative to be continuous at 0, we must have 6a + 2b = 2r. Finally, the natural spline condition is that the second derivative should be zero at the endpoints. This gives 2b = 0, 6q + 2r = 0. Putting all this together we have d = sin(1), t = 1, b = 0 a + c = 1 โˆ’ sin(1) q + r + s = sin(1) โˆ’ 1, so a + c + q + r + s = 0. 3 a + c = s 6 a = 2r, a = r/ 3 6 q + 2r = 0, so q = โˆ’r/3. Then s = r + c, r/3 + c โˆ’ r/3 + r + r + c = 0 = 2c + 2r, and c = โˆ’r, implying s = 0. We then have r/ 3 โˆ’ r = โˆ’ 2 r/3 = 1 โˆ’ sin(1), for r = โˆ’^32 (1 โˆ’ sin(1)). So we can write down P as follows: P (x) = โˆ’^12 (1 โˆ’ sin(1))(x + 1)^3 + 32 (1 โˆ’ sin(1))(x + 1) + sin(1) on [โˆ’ 1 , 0] and P (x) = 12 (1 โˆ’ sin(1))x^3 โˆ’ 32 (1 โˆ’ sin(1))x^2 + 1 on [0, 1]. (4) L = limhโ†’ 0 f (h) and L โˆ’ f (h) = c 6 h^6 + c 9 h^9 + ... We consider Lโˆ’f (h/2). This is c 6 (h/2)^6 +c 9 (h/2)^9. .. = c 6 h^6 /64+c 9 h^9 /512. To cancel the lowest order term, we compute (L โˆ’ f (h)) โˆ’ 64(L โˆ’ f (h/2)) = c 9 h^9 โˆ’ (c 9 /8)h^9. Then โˆ’ 63 L โˆ’ f (h) + 64f (h/2) = (7/8)c 9 h^9. Solving for L we find L = (64f (h/2) โˆ’ f (h) โˆ’ (7/8)c 9 h^9 )/63, so L โˆ’ (^6463 f (h/2) โˆ’ 631 f (h)) = โˆ’ 721 c 9 h^9. This is order h^9 instead of h^6 , and so is more accurate than the original estimate. (5) We have f (0) = 0, f (0.1) = 0.01, f (0.2) = 0.04.

A second-order method must give the exact solution on quadratic polyno- mials. Therefore the second-order approximation to the derivative of f using these three points must be equal to the derivative of the quadratic passing through these points. We compute this quadratic with Lagrange polynomials: P (x) = 0L 0 +

  1. 01 L 1 + 0. 04 L 2 = 0. (^01) (0. 1 xโˆ’(0)(0xโˆ’^0 .. 1 2)โˆ’ 0 .2) + 0. (^04) (0. 2 โˆ’x(0)(0xโˆ’^0. 2 .1)โˆ’ 0 .1).

This is P = โˆ’ 0. 01 x

(^2) โˆ’ 0. 2 x

  1. 01 + 0.^04

x^2 โˆ’ 0. 1 x

  1. 02 , which is equal to^ โˆ’(x

(^2) โˆ’ 0. 2 x) +

2(x^2 โˆ’ 0. 1 x) = x^2. So our second-order approximation to f โ€ฒ(x) at x = 0 is the derivative of x^2 at 0, which is 0.