21.04.2015 Views

Lecture Notes in Differential Equations - Bruce E. Shapiro

Lecture Notes in Differential Equations - Bruce E. Shapiro

Lecture Notes in Differential Equations - Bruce E. Shapiro

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

370 LESSON 33. NUMERICAL METHODS<br />

Heun’s Method is<br />

y n = y n−1 + h n<br />

4<br />

[<br />

f(t n−1 , y n−1 ) + 3f<br />

(<br />

t n−1 + 2 3 h, y n−1 + 2 )]<br />

3 hf(t n−1, y n−1 )<br />

(33.67)<br />

Both Heun’s method and the modified Euler method are second order and<br />

are examples of two-step Runge-Kutta methods. It is clearer to implement<br />

these <strong>in</strong> two “stages,” eg., for the modified Euler method,<br />

while for Heun’s method,<br />

ỹ n = y n−1 + hf(t n−1 , y n−1 ) (33.68)<br />

y n = y n−1 + h n<br />

2 [f(t n−1, y n−1 ) + f(t n , ỹ n )] (33.69)<br />

ỹ n = y n−1 + 2 3 hf(t n−1, y n−1 ) (33.70)<br />

y n = y n−1 + h [<br />

(<br />

n<br />

f(t n−1 , y n−1 ) + 3f t n−1 + 2 )]<br />

4<br />

3 h, ỹ n (33.71)<br />

Runge-Kutta Fourth Order Method. This is the “gold standard” of<br />

numerical methods - its a lot higher order than Euler but still really easy<br />

to implement. Other higher order methods tend to be very tedious – even<br />

to code – although once coded they can be very useful. Four <strong>in</strong>termediate<br />

calculations are performed at each step:<br />

Then the subsequent iteration is given by<br />

k 1 = hf(t n , y n ) (33.72)<br />

k 2 = hf(t n + .5h, y n + .5k 1 ) (33.73)<br />

k 3 = hf(t n + .5h, y n + .5k 2 ) (33.74)<br />

k 4 = hf(t n + h, y n + k 3 ) (33.75)<br />

y n+1 = y n + 1 6 (k 1 + 2k 2 + 2k 3 + k 4 ) (33.76)<br />

Example 33.2. Compute the solution to the test equation y ′ = y, y(0) = 1<br />

on [0, 1] us<strong>in</strong>g the 4-stage Runge Kutta method with h = 1/2.<br />

S<strong>in</strong>ce we start at t = 0 and need to compute through t = 1 we have to<br />

compute two iterations of RK. For the first iteration,<br />

k 1 = y 0 = 1 (33.77)

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!