Download (direct link):
The percentage errors at t = 2 for the improved Euler method are 1.22% for h = 0.025 and 0.21% for h = 0.01.
8.2 Improvements on the Euler Method
A computer program for the Euler method can be readily modified to implement the improved Euler method instead. All that is required is to replace Step 6 in the algorithm in Section 8.1 by the following:
Step 6. k 1 = f (t, y)
k2 = f (t + h, y + h * k 1) y = y + (h/2) * (k 1 + k2) t = t + h
Variation of Step Size. In Section 8.1 we mentioned the possibility of adjusting the step size as a calculation proceeds so as to maintain the local truncation error at a more or less constant level. The goal is to use no more steps than necessary, and at the same time to keep some control over the accuracy of the approximation. Here we will describe how this can be done. Suppose that after n steps we have reached the point (tn, Óï). We choose a step size h and calculate yn+1. Next we need to estimate the error we have made in calculating yn 1. In the absence of knowing the actual solution the
best that we can do is to use a more accurate method and repeat the calculation starting
from (tn, yn). For example, if we used the Euler method for the original calculation, we might repeat with the improved Euler method. Then the difference between the two calculated values is an estimate e“+1 of the error in using the original method. If the estimated error is different from the error tolerance e, then we adjust the step size and repeat the calculation. The key to making this adjustment efficiently is knowing how the local truncation error en+1 depends on the step size h. For the Euler method the local truncation error is proportional to h2, so to bring the estimated error down (or up) to the tolerance level e we must multiply the original step size by the factor Ve/e-.
To illustrate this procedure consider the example problem (7),
Ó = 1 - t + 4y, y(0) = 1.
You can verify that after one step with h = 0.1 we obtain the values 1.5 and 1.595 from the Euler method and the improved Euler method, respectively. Thus the estimated error in using the Euler method is 0.095. If we have chosen an error tolerance of 0.05, for instance, then we need to adjust the step size downward by the factor ^/0.05/0.095 =
0.73. Rounding downward to be conservative, let us choose the adjusted step size h = 0.07. Then, from the Euler formula we obtain
y1 = 1 + (0.07) f(0, 1) = 1.35 = ô(0.07).
Using the improved Euler method we obtain y1 = 1.39655, so the estimated error in using the Euler formula is 0.04655, which is slightly less than the specified tolerance. The actual error, based on a comparison with the solution itself, is somewhat greater, namely, 0.05122.
The same procedure can be followed at each step of the calculation, thereby keeping the local truncation error approximately constant throughout the entire numerical process. Modern adaptive codes for solving differential equations adjust the step size as they proceed in very much this way, although they usually use more accurate formulas than the Euler and improved Euler formulas. Consequently, they are able to achieve both efficiency and accuracy by using very small steps only where they are really needed.
Chapter 8. Numerical Methods
PROBLEMS In each of Problems 1 through 6 find approximate values of the solution of the given initial value problem at t = 0.1, 0.2, 0.3, and 0.4. Compare the results with those obtained by the Euler method and the backward Euler method in Section 8.1 and with the exact solution (if available).
(a) Use the improved Euler method with h = 0.05.
(b) Use the improved Euler method with h = 0.025.
(c) Use the improved Euler method with h = 0.0125.
> 1. y = 3 + t — y, y(0) = 1 > 2. y = 5t — 3Jy, y(0) = 2
> 3. / = 2y — 3t, y(0) = 1 > 4. y = 2t + e—ty, y(0) = 1
, y2 + 2ty
> 5. y=^+/’ y(0)=0.5
> 6. Ó = (t2 — y2) siny, y(0) = — 1
In each of Problems 7 through 12 find approximate values of the solution of the given initial value problem at t = 0.5, 1.0, 1.5, and 2.0.
(a) Use the improved Euler method with h = 0.025.
(b) Use the improved Euler method with h = 0.0125.
> 7. / = 0.5 — t + 2y, y(0) = 1 > 8. Ó = 5t — 3Jy, y(0) = 2
> 9. y = ^T+y, y(0) = 3 > 10. y = 2t + e—ty, y(0) = 1
> 11. y = (4 — ty)/(1 + y2), y(0) = -2
> 12. y = (y2 + 2ty)/(3 + t2), y(0) = 0.5
> 13. Complete the calculations leading to the entries in columns four and five of Table 8.2.1.