Docsity

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

Partial preview of the text

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

UCB Math 128A, Spring 2009: Midterm 2, Solutions

April 6, 2009

Name:

SID:

GSI:

  • No books, no notes, no calculators
  • Justify all answers
  • Do all of the 4 problems
  • Exam time 50 minutes

Grading 1 / 25 2 / 25 3 / 25 4 / 25 /

Consider the initial-value problem with exact solution y(t) = e−^2 t^ + t:

y′^ = 2(t − y) + 1, 0 ≤ t ≤ 2 , y(0) = 1

(a) Approximate y(2) using Euler’s method with step size h = 0.5.

(b) Find the value of h necessary for an error at most 10−^5 in y(2), using the error bound below (notation as in the textbook).

|y(ti) − wi| ≤ hM 2 L

[

eL(ti−a)^ − 1

]

Solution: (a)

w 0 = 1 w 1 = w 0 + hf (t 0 , w 0 ) = 1 + 0. 5 · (−1) = 0. 5 w 2 = w 1 + hf (t 1 , w 1 ) = 0.5 + 0. 5 · 1 = 1. 0 w 3 = w 2 + hf (t 2 , w 2 ) = 1.0 + 0. 5 · 1 = 1. 5 w 4 = w 3 + hf (t 3 , w 3 ) = 1.5 + 0. 5 · 1 = 2. 0 ≈ y(2)

(b) Lipschitz constant: ∣∣ ∣∣^ ∂f ∂y

∣∣ = 2 = L

Bound on second derivative of solution:

|y′′(t)| =

4 e−^2 t

≤ 4 = M

Find step size h to get an error of 10−^5 :

10 −^5 = hM 2 L

[

eL·^2 − 1

]

= h

e^4 − 1

=⇒ h = 10

− 5 e^4 − 1

Show how to use Newton’s method to solve the equation below for x: ∫ (^) x

−x

esin^ t^ dt = 1.

Use the Composite Simpson’s rule with n = 4 intervals for the integral. You do not have to perform any numerical calculations.

Solution: Apply Newton’s method to the equation

f (x) =

∫ (^) x

−x

esin^ t^ dt − 1 = 0.

The integral is approximated by the Composite Simpson’s rule with h = 2x/n = x/2: ∫ (^) x

−x

f (t) dt ≈ h 3 (f^ (−x) + 4f^ (−x/2) + 2f^ (0) + 4f^ (x/2) +^ f^ (x))^. The derivative is given by the fundamental theorem of calculus:

f ′(x) = esin^ x^ + esin^ −x.

The Newton iteration becomes:

x 0 = initial guess,

xn+1 = xn − f (xn) f ′(xn)

= xn −

xn 6

[

esin^ −xn^ + 4esin^ −xn/^2 + 2esin 0^ + 4esin^ xn/^2 + esin^ xn

]

esin^ xn^ + esin^ −xn

(a) Determine the constants a, b, α such that the quadrature rule ∫ (^1)

− 1

f (x) dx ≈ af (−1) + af (1) + bf (α) + bf (−α)

has the highest possible degree of precision. Clearly state the degree of precision of the resulting rule.

(b) Use the quadrature rule to approximate the integral below. You can use a, b, α instead of the values calculated in (a). ∫ (^4)

0

e

√x dx.

Solution: (a) Match left and right hand sides for monomials f (x) = xn:

n odd :

− 1 x n (^) dx = 0

af (−1) + af (1) + bf (α) + bf (−α) = 0

n even :

− 1 x

n (^) dx = 2/(n + 1)

af (−1) + af (1) + bf (α) + bf (−α) = 2a + 2bαn

Use n = 0, 2 , 4 and solve for a, b, α:   

 

2 a + 2b = 2

2 a + 2bα^2 = (^23)

2 a + 2bα^4 = (^25)

2 b(1 − α^2 ) = (^43)

2 b(1 − α^4 ) = (^85)

1 − α^2 1 − α^4 =

5 α^4 − 6 α^2 + 1 = 0 =⇒ α^2 =

The solution α^2 = 1 is invalid, pick the positive root α = 1/

The weights are then a = 1/6 and b = 5/6. The degree of precision of the rule is 5.