Docsity

Homework 7 Solutions for Numerical Analysis | MATH 128A, Assignments of Mathematical Methods for Numerical Analysis and Optimization

Toggle sidebar
bg1
MATH 128A, SUMMER 2009: HOMEWORK 7 SOLUTIONS
(1) Let’s use the notation wAB3 for the Adams-Bashforth(3) predictor’s estimate of yi+1,wAM2 for the
Adams-Moulton(2) corrector’s estimate of yi+1, and τAB3 and τAM2 for their respective truncation
errors.
From the textbook, we have the truncation error formulas
τAB3 =yi+1 −wAB3
h=3
8y(4)(ξAB3)h3, ξAB3 ∈[ti−2, ti+1 ]
τAM2 =yi+1 −wAM2
h≈−1
24 y(4)(ξAM2)h3, ξAM2 ∈[ti−1, ti+1 ]
(Technically speaking, the equation in the second line is approximate: it gives the predictor-
corrector method’s truncation error as that of the corrector step. The difference ends up being
O(h4), and may be ignored.)
Proceed by assuming that y(4)(ξ) is approximately constant on the relevant interval. When we
subtract the equations, the yi+1 terms cancel and we’re left with
wAM2 −wAB3
h≈10
24y(4)(?)h3
The left-hand side is −1, so y(4)(?)h3≈ −24/10. Plugging back into the formula for τAM2 gives
τAM2 ≈0.1.
(2) If u1=y,u2=y0, this system is equivalent: u1
u20
=u2
−2u1−2u2, 0 ≤t≤9.6, u1(0)
u2(0)=1
−1.
(3) Example solution with MATLAB:
>> for n=[16 12 8]
[t,w]=euler( @(t,u)[u(2), -2*u(1)-2*u(2)], 0, 9.6, [1,-1], n);
abs(w(end,1) - exp(-9.6)*cos(9.6))
end
ans =
0.0053
ans =
0.0968
ans =
1.1852
(4) (a) The metho d’s characteristic polynomial (in the sense of §5.10) is Q(λ) = λ2−1. This has roots
+1 and −1, so by definition the method is weakly stable.
(b) The values of λrelevant to the hint are exactly these roots: wi= (1)i= 1 and wi= (−1)iare
both solutions to this recurrence. Hence the general solution is wi=c1+c2(−1)i.
Date: Thursday 8/06.
1
pf2

Partial preview of the text

Download Homework 7 Solutions for Numerical Analysis | MATH 128A and more Assignments Mathematical Methods for Numerical Analysis and Optimization in PDF only on Docsity!

MATH 128A, SUMMER 2009: HOMEWORK 7 SOLUTIONS

(1) Let’s use the notation wAB3 for the Adams-Bashforth(3) predictor’s estimate of yi+1, wAM2 for the Adams-Moulton(2) corrector’s estimate of yi+1, and τAB3 and τAM2 for their respective truncation errors. From the textbook, we have the truncation error formulas

τAB3 = yi+1 − wAB h

y(4)(ξAB3)h^3 , ξAB3 ∈ [ti− 2 , ti+1]

τAM2 = yi+1 − wAM h

y(4)(ξAM2)h^3 , ξAM2 ∈ [ti− 1 , ti+1]

(Technically speaking, the equation in the second line is approximate: it gives the predictor- corrector method’s truncation error as that of the corrector step. The difference ends up being O(h^4 ), and may be ignored.) Proceed by assuming that y(4)(ξ) is approximately constant on the relevant interval. When we subtract the equations, the yi+1 terms cancel and we’re left with wAM2 − wAB h

y(4)(?)h^3

The left-hand side is −1, so y(4)(?)h^3 ≈ − 24 /10. Plugging back into the formula for τAM2 gives τAM2 ≈ 0 .1. (2) If u 1 = y, u 2 = y′, this system is equivalent:

[

u 1 u 2

]′

[

u 2 − 2 u 1 − 2 u 2

]

, 0 ≤ t ≤ 9 .6,

[

u 1 (0) u 2 (0)

]

[

]

(3) Example solution with MATLAB:

for n=[16 12 8] [t,w]=euler( @(t,u)[u(2), -2u(1)-2u(2)], 0, 9.6, [1,-1], n); abs(w(end,1) - exp(-9.6)*cos(9.6)) end

ans =

ans =

ans =

(4) (a) The method’s characteristic polynomial (in the sense of §5.10) is Q(λ) = λ^2 − 1. This has roots +1 and −1, so by definition the method is weakly stable. (b) The values of λ relevant to the hint are exactly these roots: wi = (1)i^ = 1 and wi = (−1)i^ are both solutions to this recurrence. Hence the general solution is wi = c 1 + c 2 (−1)i.

Date: Thursday 8/06. 1

(c) By part (b), in the small-h limit {wi} looks like an accurate (constant) approximation of yi plus a deviation which changes sign on each step. The graph’s jaggedness simply shows that such behavior is already visible when h = 0.1. (d) Smoothing should preserve the trend in the {wi} because each wi is averaged with its neighbors. [It also helps that the weights on wi− 1 and wi+1 are equal.] On the other hand, it should roughly cancel the oscillations noticed in (b). For instance, 14 ((−1)i−^1 + 2(−1)i^ + (−1)i+1) = 0. The graph confirms this. (5) (a) If we feed Euler’s method f (t, y) = λy, the steps will be wi+1 = wi + hλwi = (1 + hλ)wi. This decays to zero iff |1 + hλ| < 1. (b) If we feed the backward Euler method f (t, y) = λy, the steps will be wi+1 = wi + hλwi+1. The solution to this equation is wi+1 = (^1) −^1 hλ wi. This decays to zero iff | 1 − hλ|−^1 < 1, iff | 1 − hλ| > 1. (In particular, this decays to zero when hλ lies on the left side of the imaginary axis: the backward Euler method is A-stable.) (c) The system from problem 2 has characteristic equation λ^2 + 2λ + 2 = 0. Thus its eigenvalues are λ = − 1 ± i. [This means that after a linear change of coordinates the system looks like x′ 1 = (− 1 − i)x 1 , x′ 2 = (−1 + i)x 2 .] Therefore, we expect (roughly) that method can handle this problem without stability issues as long as the numbers (− 1 ± i)h are in the stability region. For the backward Euler method, this doesn’t restrict the values of h at all. For Euler’s method,this does restrict h: We need 1 > |1 + (−1 + i)h| = |(1 − h) + (h)i|. Squaring both sides, we get 1 > (1 − h)^2 + h^2 = 2h^2 − 2 h + 1. So we need h < 1.

2