Вы находитесь на странице: 1из 4

6.2.2.

The Modified Euler Method


The Euler method can be modified so that each step is accurate to O(h2). As an example, consider the pair of 1st order equations [ cf. the rabbits-foxes equations (6.7) ], & r = R ( r, f ) and &= F ( r, f ) f (6.9)

The modified Euler equations are 1 rk +1 = rk + h ( R1 [ k ] + R2 [ k ] ) 2 f k +1 = f k + where tk +1 = tk + h R1 [ k ] = R ( rk , f k ) rk = r ( tk ) f k = f ( tk ) F1 [ k ] = F ( rk , f k ) 1 F ( R1 [ k ] + R2 [ k ] ) 2 (6.10)

R2 [ k ] = R ( rk + hR1 [ k ] , f k + hF1 [ k ] ) F2 [ k ] = F ( rk + hR1 [ k ] , f k + hF1 [ k ] ) [See 6.3.1 for a hint of proof.] Application to the rabbits-foxes equations is described in Example 6-3: Modified Euler Algorithm 06-3.nb The phase space trajectory for the same parameters as used in Example 6-2, except for the change from n = 1000 to n = 2000, is plotted in Fig.6.5. Significant improvements over the Euler result are evident. In particular, the trajectory remains a closed loop, as it should, even after twice the number of steps as taken in Example 6-2. A price to pay for the higher accuracy is more complicated calculations at each step. Thus, the modified version is always slower that the original Euler method. One way to lessen this penalty is to increase the step size h. Unfortunately, the solution tends to become unstable if h is too large [ see Fig.6.7, where h = 0.570 ]. Indeed, the quality of the solution has already begun to deteriorate for h = 0.565 [see Fig.6.6]. As always, trade-off must be made.

As another illustration of the damages that an outsized h can do, consider the ODE y = 10 y (6.11)
10 x with y ( 0 ) = 1 . The exact solution is easily found to be y ( x ) = e . Applying the

Euler method, we get yk +1 = yk h 10 yk = ( 1 10h ) yk (6.12)

To see the effects of increasing h, we start with a relatively small value of h = 0.05. The results calculated from (6.12) are tabulated as follows k yk yexact 0 1 1 1 0.5 0.60 7 2 0.25 0.36 8 3 0.12 5 0.22 3 4 0.0625 0.135

where we have also listed the exact values to 3 significant digits. For h = 0.1, eq(6.12) gives yk = 0 for all k = 1, 2, 3, . It should come as no surprise that instability sets in for h > 0.1. For example, if h = 0.15, then k y
k

0 1

1 0. 5

2 0.2 5

3 0.12 5

4 0.0625

Thus, the solution oscillates instead of decaying exponentially any resemblance to the actual solution has been lost.

Fig.6.5. Modified Euler algorithm applied to r-f equations.

Fig.6.6. Behavior of r-f equations for h = 0.565 in modified Euler code.

Fig.6.7. Onset of numerical instability in modified Euler code for h = 0.570.

Вам также может понравиться