Vous êtes sur la page 1sur 4

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 ,
h k1
k2 = hf ti + , wi + ,
2 2
h k2 (1)
k3 = hf ti + , wi + ,
2 2
k4 = hf ti + h, wi + k3 ,
1
wi+1 = wi + k1 + 2k2 + 2k3 + k4 ,
6
when applied to the differential equation y 0 = y, can be written in the form

1 1 1
wi+1 = 1 + h + (h)2 + (h)3 + (h)4 wi .
2 6 24

Solution: We have
1
wi+1 = wi + k1 + 2k2 + 2k3 + k4
6
1 1 h 1
= wi + hf ti , wi + hf ti + , wi + hf ti , wi
6 3 2 2

1 h 1 h 1
+ hf ti + , wi + hf ti + , wi + hf ti , wi
3 2 2 2 2

1 h 1 h 1
+ hf ti + h, wi + hf ti + , wi + hf ti + , wi + hf ti , wi .
6 2 2 2 2
Since y 0 = y = f (t, y), we have

1 1 1
wi+1 = wi + hwi + h wi + hwi
6 3 2

1 1 1
+ h wi + h wi + hwi
3 2 2

1 1 1
+ h wi + h wi + h wi + hwi
6 2 2

1 1 1
= wi 1 + h + h + (h)2
6 3 6
1 1 1
+ h + (h)2 + (h)3
3 6 12
1 1 1 1
+ h + (h)2 + (h)3 + (h)4
6 6 12 24

1 2 1 3 1 4
= 1 + h + (h) + (h) + (h) wi . X
2 6 24

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

w0 = ,
hh i
wi+1 = wi + f (ti+1 , wi+1 ) + f (ti , wi ) ,
2
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 0 = 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
h
wi+1 = wi + (wi+1 + wi ),
2
h h
wi+1 wi+1 = wi + wi ,
2 2
1 + h
2
wi+1 = wi ,
1 h
2
n+1
1 + h
2
wi+1 = w0 .
1 h
2

Thus,
h
1+ 2 2 + h
Q(h) = h
= .
1 2
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 = 105
y 0 = 20(y t)2 + 2t, 0 t 1,
1 (2)
y(0) = ,
3
with h = 0.1. Compare the results with the actual solution y(t) = t2 + 13 e20t .

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 0 = t2 2e2t , 0 t 1,
(3)
y(0) = 1,

t3
with h = 0.1. Compare the results with the actual solution y(t) = + e2t .
3
Solution: For this problem, we compute starting values wi , i = 1, 2, 3 using the fourth
order Runge-Kutta method:

k1 = hf ti , wi ,
h k1
k2 = hf ti + , wi + ,
2 2
h k2 (4)
k3 = hf ti + , wi + ,
2 2

k4 = hf ti + h, wi + k3 ,
1
wi+1 = wi + k1 + 2k2 + 2k3 + k4 .
6
For i = 4, 5, ... 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:
h
wi+1 = wi + 55f (ti , wi ) 59f (ti1 , wi1 ) + 37f (ti2 , wi2 ) 9f (ti3 , wi3 ) . (5)
24
The fourth-order Adams-Moulton technique, an implicit three-step method, is defined as:
h
wi+1 = wi + 9f (ti+1 , wi+1 ) + 19f (ti , wi ) 5f (ti1 , wi1 ) + f (ti2 , wi2 ) . (6)
24

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
h
wi+1 = wi + 23f (ti , wi ) 16f (ti1 , wi1 ) + 5f (ti2 , wi2 ) (7)
12
by the following method. Set

y(ti+1 ) = y(ti ) + ahf (ti , y(ti )) + bhf (ti1 , y(ti1 )) + chf (ti2 , y(ti2 )). (8)

Expand y(ti+1 ), f (ti2 , y(ti2 )), and f (ti1 , y(ti1 )) in Taylor series about (ti , y(ti )), and
equate the coefficients of h, h2 , and h3 to obtain a, b, and c.

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

y(ti+1 ) = y(ti ) + ahy 0 (ti ) + bhy 0 (ti1 ) + chy 0 (ti2 ). (9)

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

y(ti ) + hy 0 (ti ) + 12 h2 y 00
(ti ) + 16 h3 y 000 (ti ) + O(h4 )
= y(ti ) + ahy 0 (ti ) + bh y 0 (ti ) hy 00 (ti ) + 21 h2 y 000 (ti ) + O(h3 )

+ch y 0 (ti ) 2hy 00 (ti ) + 42 h2 y 000 (ti ) + O(h3 ) ,

= y(ti ) + a + b + c hy 0 (ti ) + b 2c h2 y 00 (ti ) + 12 b + 2c h3 y 000 (ti ) + O(h4 ).
Thus, equating the coefficients, we obtain

1 = a + b + c,
1
= b 2c,
2
1 1
= b + 2c,
6 2
23 16 5
which gives a = , b = , c = . Plugging these into (8), we obtain
12 12 12
h
y(ti+1 ) = y(ti ) + 23f (ti , y(ti )) 16f (ti1 , y(ti1 )) + 5f (ti2 , y(ti2 )) + O(h4 ),
12
or
h
wi+1 = wi + 23f (ti , wi ) 16f (ti1 , wi1 ) + 5f (ti2 , wi2 ) .
12
The order of the local truncation for the Adams-Bashforth three-step explicit method is,
therefore, (h) = O(h3 ).

Vous aimerez peut-être aussi