Sunteți pe pagina 1din 4

Homework 3 Solutions

Igor Yanovsky (Math 151B TA)

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

k 1 = hf t i , w i ,

k

2

= hf t i + h , w i + k 1 ,

2

2

k 3 = hf t i + h , w i + k 2 ,

k 4 =

w i+1 = w i +

2

2

hf t i + h, w i + k 3 ,

1

6 k 1 + 2k 2 + 2k 3 + k 4 ,

(1)

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

w i+1

= 1 + + 2 () 2

1

+ 6 () 3 + 24 () 4 w i .

1

1

Solution:

w i+1

We have

=

=

w i +

w i +

1

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

1 6 hf t i , w i + 3 hf t i + h 2 ,

1

w i + 2 hf t i , w i

1

+ 3 hf t i + h

1

2 , w i + 2 hf t i + h , w i + 1

1

2

2 hf t i , w i

+ 6 hf t i + h, w i + hf t i + h

1

2 , w i + 2 hf t i + h

1

2 , w i + 2 hf t i , w i .

1

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

w i+1

=

=

=

w i + 6 hλw i + 3 w i + 1 2 hλw i

1

1

+ 3 w i + 2 w i + 2 hλw i

1

1

1

+ 6 w i + w i + 2 w i + 2 hλw i

1

1

1

w i 1 + 6 + 3 + 6 () 2

1

1

1

+ + 12 () 3

1

6 () 2

1

+ 6 + 6 () 2

3 1 +

1

1

+ 12 () 3 + 24 () 4

1

1

1 + + 2 () 2 + 6 () 3 + 24 () 4 w i .

1

1

1

1

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

w 0 = α,

w

i+1 = w i + h

2

is A-stable.

f(t i+1 , w i+1 ) + f(t i , w i ) ,

Solution: The region R of absolute stability is R = {C | |Q()| < 1}, where w i+1 = Q()w i . 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

Thus,

w

i+1

= w i + h

2

(λw i+1 + λw i ),

w i+1 − hλ w i+1 = w i + hλ w i , 2
w i+1 − hλ w i+1 = w i + hλ
w i ,
2
2
1 + hλ
2
w i ,
w i+1 =
1 − hλ
2
n+1
2
w i+1 = 1 + hλ
w 0 .
1 − hλ
2
= 2 + hλ
2
Q(hλ) = 1 + hλ
1 − hλ
2 − hλ .
2

Note that for Re() < 0, |Q()| < 1, and for Re() > 0, |Q()| > 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,

y(0) = 1

3 ,

0 t 1,

with h = 0.1. Compare the results with the actual solution y(t) = t 2 +

1 e 20t .
3

(2)

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.87754e 002.

2

Section 5.6, Problem 6(a): THERE IS A TYPO IN THE BOOK. THE SOLUTION TO THE INITIAL VALUE PROBLEM DOES NOT MATCH THE ACTUAL SOLU- TION. WE WILL BE USING A DIFFERENT ODE.

Use Adams Fourth-Order Predictor-Corrector algorithm of section 5.6 to approximate the solutions to the initial-value problem

y =

y(0) = 1,

t 2

2e 2t ,

0 t 1,

3

with h = 0.1. Compare the results with the actual solution y(t) = t 3 + e 2t .

(3)

Solution:

order Runge-Kutta method:

For this problem, we compute starting values w i , i = 1, 2, 3 using the fourth

k 1 = hf t i , w i ,

k

2

= hf t i + h , w i + k 1 ,

2

2

hf t i + h , w i + k 2 ,

2

2

hf t i + h, w i + k 3 ,

k 3 =

k 4 =

w i+1 = w i +

1

6 k 1 + 2k 2 + 2k 3 + k 4 .

(4)

we use Adams Fourth-Order Predictor-Corrector method, which consists

of the predictor Adams-Bashforth, and corrector Adams-Moulton techniques. The fourth-order Adams-Bashforth technique, an explicit four-step method, is defined as:

For i = 4, 5,

w i+1 = w i +

h

24

55f (t i , w i ) 59f (t i1 , w i1 ) + 37f (t i2 , w i2 ) 9f(t i3 , w i3 ) .

(5)

The fourth-order Adams-Moulton technique, an implicit three-step method, is defined as:

w i+1 = w i +

h

24

9f(t i+1 , w i+1 ) + 19f (t i , w i ) 5f(t i1 , w i1 ) + f(t i2 , w i2 ) .

(6)

Running the Adams Fourth-Order Predictor-Corrector algorithm gives the following re- sults at the final step:

N

= 10, h = 1.0000000e 001, t = 1.00,

w

= 4.6864787414e 001, y = 4.6866861657e 001, error = 2.0742429498e 005.

You can verify that the solutions obtained with the method are indeed satisfying the fourth order accuracy. Check this, for example, running the code with h = 0.01 and h = 0.005 and calculate the order of convergence using the formula from homework 2.

3

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

w i+1 = w i +

h

12 23f (t i , w i ) 16f (t i1 , w i1 ) + 5f(t i2 , w i2 )

by the following method. Set

(7)

y(t i+1 ) =

y(t i ) + ahf (t i , y(t i )) + bhf (t i1 , y(t i1 )) + chf (t i2 , y(t i2 )).

(8)

Expand y(t i+1 ),

f (t i2 , y(t i2 )), and f (t i1 , y(t i1 )) in Taylor series

about

(t i , y(t i )), and

equate the coefficients of h, h 2 , and h 3 to obtain a, b, and c.

Solution:

Since y (t i )

= f(t i , y(t i )), we can write equation (8) as

y(t i+1 ) = y(t i ) + ahy (t i ) + bhy (t i1 ) + chy (t i2 ).

 

(9)

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

y(t i ) + hy (t i ) +

= y(t i ) + ahy (t i ) + bh y (t i ) hy (t i ) + 2 h 2 y (t i ) + O(h 3 )

1 2 h 2 y (t i ) + 6 h 3 y (t i ) + O(h 4 )

1

1

+ch y (t i ) 2hy (t i ) + 4 h 2 y (t i ) + O(h 3 ) ,

2

1

= y(t i ) + a + b + c hy (t i ) + b 2c h 2 y (t i ) + 2 b + 2c h 3 y (t i ) + O(h 4 ).

Thus, equating the coefficients, we obtain

1

1

2

1

6

=

=

=

a + b + c, b 2c,

1 2 b + 2c,

which gives a = 23 ,

12

b

= 16

5

12 , c = 12 . Plugging these into (8), we obtain

y(t i+1 ) = y(t i ) +

h

12 23f (t i , y(t i )) 16f (t i1 , y(t i1 )) + 5f (t i2 , y(t i2 )) + O(h 4 ),

or

w i+1 = w i +

h

12 23f (t i , w i ) 16f (t i1 , w i1 ) + 5f(t i2 , w i2 ) .

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

4