Docsity

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

Toggle sidebar
bg1
UCB MATH 128A-002, SUMMER 2009: MIDTERM 2 SOLUTIONS
1. Fill in the blanks below as accurately as possible.
x0 0.5 +1
f(x) 1 3
f0(x)
R1
0f(x)dx ≈
Solution: All answers end up being 2.
The easy way: the best we can do is assume f(x) is a line, so let f(x) = 1 + 2xand fill the boxes.
Harder method:
Estimate f(0.5) by linear interpolation (i.e., averaging): f(0.5) ≈1+3
2= 2 .
Estimate f0(0), f0(0.5), and f0(1) with the forward-, centered-, and backward-difference formulas
(with h= 0.5 in the case of f0(0.5)). They all end up calculating the same thing: the slope 3−1
1= 2 .
Estimate R1
0f(x)dx with the trapezoidal rule: 1
2(1 + 3) = 2 .
2. Let T(h) denote the composite trapezoidal estimate of R1
0f(x)dx, with step size h.
You have measured T(0.2) = 3.0 and T(0.1) = 3.3. Assume that the composite trapezoidal rule
makes error R1
0f(x)dx −T(h)≈Kh2(for a non-zero constant K).
(a) Estimate the exact value of R1
0f(x)dx as accurately as possible.
(b) Estimate the absolute error
R1
0f(x)dx −T(0.1)
as accurately as possible.
(c) Estimate how small hmust be for T(h) to approximate R1
0f(x)dx to within 10−3
Solution: 3.0−3.3≈K(0.2)2−K(0.1)2= 0.03K, so K≈−0.3
0.03 =−10.
(a) R1
0f(x)dx ≈T(0.1) −K(0.1)2= 3.4 .
(b)
R1
0f(x)dx −T(0.1)
≈ |K(0.1)2|= 0.1 .
(c) |Kh2|<10−3⇐⇒ h2<10−4⇐⇒ h < 10−2.
3. Find the largest possible degree of precision for the following quadrature rule, and the corresponding
values of aand b:
Z1
−1
f(x)dx ≈af −5
6+bf(0) + af +5
6.
Solution:
Degree of precision ≥0,if 2a+b=Z1
−1
x0dx = 2 (∗)
Degree of precision ≥1,if 0 =Z1
−1
x1dx = 0 (trivial)
Degree of precision ≥2,if 2 5
62
a=Z1
−1
x2dx =2
3(∗∗)
Date: Tuesday 7/28.
1
pf2

Partial preview of the text

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

UCB MATH 128A-002, SUMMER 2009: MIDTERM 2 SOLUTIONS

  1. Fill in the blanks below as accurately as possible.

x 0 0. 5 +

f (x) 1 3

f ′ (x) ∫ (^1)

0 f (x) dx ≈

Solution: All answers end up being 2.

The easy way: the best we can do is assume f (x) is a line, so let f (x) = 1 + 2x and fill the boxes.

Harder method:

Estimate f (0.5) by linear interpolation (i.e., averaging): f (0.5) ≈

1+ 2

Estimate f

′ (0), f

′ (0.5), and f

′ (1) with the forward-, centered-, and backward-difference formulas

(with h = 0.5 in the case of f

′ (0.5)). They all end up calculating the same thing: the slope

3 − 1 1

Estimate

1 0

f (x) dx with the trapezoidal rule:

1 2

  1. Let T (h) denote the composite trapezoidal estimate of

0

f (x) dx, with step size h.

You have measured T (0.2) = 3.0 and T (0.1) = 3.3. Assume that the composite trapezoidal rule

makes error

0 f (x) dx − T (h) ≈ Kh

2 (for a non-zero constant K).

(a) Estimate the exact value of

1 0

f (x) dx as accurately as possible.

(b) Estimate the absolute error

1 0

f (x) dx − T (0.1)

∣ as accurately as possible.

(c) Estimate how small h must be for T (h) to approximate

0 f (x)dx to within 10

− 3

Solution: 3. 0 − 3. 3 ≈ K(0.2)

2 − K(0.1)

2 = 0. 03 K, so K ≈

− 0. 3

  1. 03

(a)

1 0

f (x) dx ≈ T (0.1) − K(0.1)

2 = 3..

(b)

1 0

f (x) dx − T (0.1)

∣ ≈ |K(0.1)

2 | = 0..

(c) |Kh

2 | < 10

− 3 ⇐⇒ h

2 < 10

− 4 ⇐⇒ h < 10

− 2 .

  1. Find the largest possible degree of precision for the following quadrature rule, and the corresponding

values of a and b:

− 1

f (x) dx ≈ af

  • bf (0) + af

Solution:

Degree of precision ≥ 0 , if 2 a + b =

− 1

x

0 dx = 2 (∗)

Degree of precision ≥ 1 , if 0 =

1

− 1

x

1 dx = 0 (trivial)

Degree of precision ≥ 2 , if 2

a =

− 1

x

2 dx =

Date: Tuesday 7/28.

1

By (∗∗), a =

. By (∗), b =

. We may now check:

Degree of precision ≥ 3 , if 0 =

1

− 1

x

3 dx = 0 (true)

Degree of precision ≥ 4 , if 2

1

− 1

x

4 dx =

(false)

Therefore, the degree of precision is 3.

  1. Consider the initial value problem y ′ (t) = t 2 + 2y (t ∈ [0, 4]) with y(0) = 0.

(a) Fill in the blanks using Euler’s method:

t 0. 0 1. 0 2. 0 3. 0 4. 0

y(t) 0. 0

(b) Find a Lipschitz constant L for the problem.

(c) Find a formula for y

′′ in terms of t and y.

(d) Redo (a) with a Taylor method, order 2.

Solution:

(a) The iteration is wi+1 = wi + (1)(t 2 i

  • 2wi) = t 2 i
  • 3wi. Result:

t 0. 0 1. 0 2. 0 3. 0 4. 0

y(t) 0 0 1 7 30

(b)

∂ ∂y (t

2

  • 2y)

∣ = 2 is bounded above by L = 2.

(c) y ′′ =

d dt

(t 2

  • 2y) = 2t + 2y ′ = 2t + 2(t 2
  • 2y) = 2(t

2

  • t + 2y).

(d) The iteration is wi+1 = wi + (1)(t 2 i

  • 2wi) +

(1) 2

2

2(t 2

  • t + 2y) = 2t 2 i
  • ti + 5wi. Result:

t 0. 0 1. 0 2. 0 3. 0 4. 0

y(t) 0 0 3 25 146

  1. Find the order of the local truncation error τi+1 in this rule for solving y ′ = f (t, y):

wi+1 = wi + hf (ti + h, wi).

Solution: Compute Taylor terms...

... for y(ti + h) (using Taylor series for y(t)

centered at ti):

y(t) = y(t)

→ wi

y

′ (t) = f (t, y(t))

→ f (ti, wi)h

y

′′ (t) = ft(t, y(t)) + fy (t, y(t))f (t, y(t))

→ [ft(ti, wi) + fy (ti, wi)f (ti, wi)]

h 2

... for wi+1 (as a function of h):

wi+1 = wi + hf (ti + h, wi)

→ wi

w

′ i+1 =^ f^ (ti^ +^ h, wi) +^ hft(ti^ +^ h, wi)

→ f (ti, wi)h

w

′′ i+ = 2ft(ti + h, wi) + hftt(ti + h, wi)

→ [2ft(ti, wi)]

h 2

Since the degree-2 Taylor terms don’t match, yi+1 − wi+1 = O(h

2 ). Thus τi+1 = O(h).

2