Solve the IVP \acute{y}= y − t , y(0) = 0.5 exactly, and use Euler’s method with the step sizes h = 0.2 and h = 0.1 to estimate the value of y(1). Hence analyze the effect that step size has on error in the method.
Solve the IVP \acute{y}= y − t , y(0) = 0.5 exactly, and use Euler’s method with the step sizes h = 0.2 and h = 0.1 to estimate the value of y(1). Hence analyze the effect that step size has on error in the method.
We first observe that y´= y −t is a linear first-order DE. Applying our work from section 2.3, we can determine that the solution to this equation is y =1+t +Ce^{t} . The initial condition y(0)=0.5 then implies that C =−1/2, so that the solution to the IVP is
y(t ) = 1+t − \frac {e^{t}}{2}
If we apply Euler’s method with h = 0.2 and take 5 steps to determine y_{n} at each, and also evaluate y(y_{n} ) at each stage, the resulting output is shown in table 2.2.
Table 2.2 Euler’s method applied to the IVP y´=y −t, y(0)=0.5, using h=0.2
Error | Solution | Euler Est. | |
| yt_{n}−y_{n}| | yt_{n} | y_{n} | t_{n} |
0 | 0.5 | 0.5 | 0 |
0.0107014 | 0.5892986 | 0.6 | 0.2 |
0.0259123 | 0.6540877 | 0.68 | 0.4 |
0.0470594 | 0.6889406 | 0.736 | 0.6 |
0.0759705 | 0.6872295 | 0.7632 | 0.8 |
0.1149809 | 0.6408591 | 0.75584 | 1.0 |
Here, we observe the obvious pattern that the further we step away from the initial condition, the greater the error we encounter. This is a natural consequence of the use of linear approximations.
To get a further sense of how the error at a given step depends on step size, we now apply the same method with h = 0.1. Doing so produces the results in table 2.3. For ease of display and comparison to the case where h = 0.2, we only report the results from every other step.
Table 2.3
Euler’s method applied to the IVP y´= y −t, y(0) = 0.5, using h = 0.1
Error | Solution | Euler Est. | |
| yt_{n}−y_{n}| | yt_{n} | y_{n} | t_{n} |
0 | 0.5 | 0.5 | 0 |
0.0057014 | 0.5892986 | 0.595 | 0.2 |
0.0138623 | 0.6540877 | 0.66795 | 0.4 |
0.0252789 | 0.6889406 | 0.7142195 | 0.6 |
0.0409761 | 0.6872295 | 0.728205595 | 0.8 |
0.0622697 | 0.6408591 | 0.70312877 | 1 |
By comparing the approximations in the preceding two tables at the common values of t = 0.2,0.4,0.8,1 we can see that cutting the step size in half appears to have reduced the error by a factor of approximately 2.