Docsity

Homework 3 Solutions - Applied Numerical Methods | MATH 151A, Assignments of Mathematics

Toggle sidebar
bg1
Homework 3 Solutions
Igor Yanovsky (Math 151B TA)
Section 5.11, Problem 10: Show that the fourth-order Runge-Kutta method,
k1=hf¡ti, wi¢,
k2=hfµti+h
2, wi+k1
2,
k3=hfµti+h
2, wi+k2
2,
k4=hf¡ti+h, wi+k3¢,
wi+1 =wi+1
6¡k1+ 2k2+ 2k3+k4¢,
(1)
when applied to the differential equation y0=λy, can be written in the form
wi+1 =µ1 + hλ +1
2(hλ)2+1
6(hλ)3+1
24(hλ)4wi.
Solution: We have
wi+1 =wi+1
6¡k1+ 2k2+ 2k3+k4¢
=wi+1
6hf¡ti, wi¢+1
3hfµti+h
2, wi+1
2hf¡ti, wi¢
+1
3hfµti+h
2, wi+1
2hfµti+h
2, wi+1
2hf¡ti, wi¢¶¶
+1
6hfµti+h, wi+hfµti+h
2, wi+1
2hfµti+h
2, wi+1
2hf¡ti, wi¢¶¶¶.
Since y0=λy =f(t, y), we have
wi+1 =wi+1
6hλwi+1
3hλµwi+1
2hλwi
+1
3hλµwi+1
2hλµwi+1
2hλwi¶¶
+1
6hλµwi+hλµwi+1
2hλµwi+1
2hλwi¶¶¶
=wiµ1 + 1
6hλ +1
3hλ +1
6(hλ)2
+1
3hλ +1
6(hλ)2+1
12(hλ)3
+1
6hλ +1
6(hλ)2+1
12(hλ)3+1
24(hλ)4
=µ1 + hλ +1
2(hλ)2+1
6(hλ)3+1
24(hλ)4wi.X
1
pf3
pf4

Partial preview of the text

Download Homework 3 Solutions - Applied Numerical Methods | MATH 151A and more Assignments Mathematics in PDF only on Docsity!

Homework 3 Solutions

Igor Yanovsky (Math 151B TA)

Section 5.11, Problem 10: Show that the fourth-order Runge-Kutta method,

k 1 = hf

ti, wi

k 2 = hf

ti + h 2

, wi + k^1 2

k 3 = hf

ti +

h 2 , wi^ +^

k 2 2

k 4 = hf

ti + h, wi + k 3

wi+1 = wi +^16

k 1 + 2k 2 + 2k 3 + k 4

when applied to the differential equation y′^ = λy, can be written in the form

wi+1 =

1 + hλ +

2 (hλ)

2 +^1

6 (hλ)

3 +^1

24 (hλ)

4

wi.

Solution: We have

wi+1 = wi +^1 6

k 1 + 2k 2 + 2k 3 + k 4

= wi +^1 6

hf

ti, wi

+^1

hf

ti + h 2

, wi +^1 2

hf

ti, wi

3 hf

ti +

h 2 , wi^ +

2 hf

ti +

h 2 , wi^ +

2 hf^

ti, wi

6 hf

ti + h, wi + hf

ti +

h 2 , wi^ +

2 hf

ti +

h 2 , wi^ +

2 hf^

ti, wi

Since y′^ = λy = f (t, y), we have

wi+1 = wi +^16 hλwi +^13 hλ

wi +^12 hλwi

+^1

hλ

wi +^1 2

hλ

wi +^1 2

hλwi

+^1

hλ

wi + hλ

wi +^1 2

hλ

wi +^1 2

hλwi

= wi

1 +^1

hλ +^1 3

hλ +^1 6

(hλ)^2

+^1 3

hλ +^1 6

(hλ)^2 +^1 12

(hλ)^3

+^1 6

hλ +^1 6

(hλ)^2 +^1 12

(hλ)^3 +^1 24

(hλ)^4

1 + hλ +

2 (hλ)

2 +^1

6 (hλ)

3 +^1

24 (hλ)

4

wi. X

Section 5.11, Problem 15(a): Show that the Implicit Trapezoidal method

w 0 = α, wi+1 = wi + h 2

[

f (ti+1, wi+1) + f (ti, wi)

]

is A-stable.

Solution: The region R of absolute stability is R = {hλ ∈ C | |Q(hλ)| < 1 }, where wi+1 = Q(hλ)wi. A numerical method is said to be A-stable if its region of stability R contains the entire left half-plane. In other words, in order to show that the method is A-stable, we need to show that when it is applied to the scalar test equation y′^ = λy = f , whose solutions tend to zero for λ < 0, all the solutions of the method also tend to zero for a fixed h > 0 as i → ∞. For the Implicit Trapezoidal method, we have

wi+1 = wi +

h 2 (λwi+1^ +^ λwi), wi+1 − hλ 2

wi+1 = wi + hλ 2

wi,

wi+1 =

1 + hλ 2 1 − hλ 2

wi,

wi+1 =

1 + hλ 2 1 − hλ 2

)n+ w 0.

Thus,

Q(hλ) =

1 + hλ 2 1 − hλ 2

2 + hλ 2 − hλ.

Note that for Re(hλ) < 0, |Q(hλ)| < 1, and for Re(hλ) > 0, |Q(hλ)| > 1. Therefore, the region of absolute stability R for the Implicit Trapezoidal methods is the entire left half-plane, and hence, the method is A-stable.

Section 5.11, Problem 7(b): Solve the following stiff initial-value problem using the Trapezoidal Algorithm with T OL = 10−^5

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

with h = 0.1. Compare the results with the actual solution y(t) = t^2 + 13 e−^20 t.

Solution: Slightly modifying the code I posted on my homepage for the problem above and running it gives the following results: N = 10, h = 0. 1 , t = 1. 0 , w = 1. 0488 , y = 1. 0000 , error = 4. 87754 e − 002.

Section 5.6, Problem 12: Derive the Adams-Bashforth three-step explicit method

wi+1 = wi + h 12

[

23 f (ti, wi) − 16 f (ti− 1 , wi− 1 ) + 5f (ti− 2 , wi− 2 )

]

by the following method. Set

y(ti+1) = y(ti) + ahf (ti, y(ti)) + bhf (ti− 1 , y(ti− 1 )) + chf (ti− 2 , y(ti− 2 )). (8)

Expand y(ti+1), f (ti− 2 , y(ti− 2 )), and f (ti− 1 , y(ti− 1 )) in Taylor series about (ti, y(ti)), and equate the coefficients of h, h^2 , and h^3 to obtain a, b, and c.

Solution: Since y′(ti) = f (ti, y(ti)), we can write equation (8) as

y(ti+1) = y(ti) + ahy′(ti) + bhy′(ti− 1 ) + chy′(ti− 2 ). (9)

Expanding both sides of (9) in Taylor series about ti, we obtain

y(ti) + hy′(ti) + 12 h^2 y′′(ti) + 16 h^3 y′′′(ti) + O(h^4 ) = y(ti) + ahy′(ti) + bh

y′(ti) − hy′′(ti) + 12 h^2 y′′′(ti) + O(h^3 )

+ch

y′(ti) − 2 hy′′(ti) + 42 h^2 y′′′(ti) + O(h^3 )

= y(ti) +

a + b + c

hy′(ti) +

− b − 2 c

h^2 y′′(ti) +

2 b^ + 2c

h^3 y′′′(ti) + O(h^4 ).

Thus, equating the coefficients, we obtain

1 = a + b + c, 1 2

= −b − 2 c, 1 6

b + 2c,

which gives a =^23 12

, b = − 16 12

, c = 5 12

. Plugging these into (8), we obtain

y(ti+1) = y(ti) +

h 12

[

23 f (ti, y(ti)) − 16 f (ti− 1 , y(ti− 1 )) + 5f (ti− 2 , y(ti− 2 ))

]

  • O(h^4 ),

or

wi+1 = wi + 12 h

[

23 f (ti, wi) − 16 f (ti− 1 , wi− 1 ) + 5f (ti− 2 , wi− 2 )

]

The order of the local truncation for the Adams-Bashforth three-step explicit method is, therefore, τ (h) = O(h^3 ).