I am doing some questions on modified Euler method (=Heun, expl. trapezium) and would appreciate some help with this one. The differential equation is $$\frac{dy}{dx}+2y=e^{3t}, ~~0\leq t\leq 1,~~ y(0)=1.$$
I found out that the exact solution is $y(t)=\frac{e^{3t}}{5}+\frac{4e^{-2t}}{5}$.
The question requires me to find the numerical global error of the modified Euler method by using values of $y(1)$ found by using $h=1$ and $h=0.5$ in the modified Euler method.
So far I calculated
- $y(1) \approx 5.8316$ using $h=0.5$ and
- $y(1) \approx 10.5428$ using $h=1$.
- Exact value at $t=1$ is $y_E(1)=4.1254$.
So the error when $h=0.5$ is $5.8316-4.1254=1.7062$ and that for $h=1$ is $6.4174$.
Next I assumed the error to be of order $h^a$. So, the error when order is $h^a$ is $6.4174$, then when error is ${\left (\frac{h}{2}\right )}^a$ error is $\frac{6.4174}{2^a}$ and evaluated this value to be equal to $1.706$ and found $a=1.9112$.
Is this the correct way or there is some formula for calculating error for modified Euler method. I could not find any so far.
I would write the assumptions about the error a little more explicitly, then you have less problems explaining what you do. That the error order is $a$ can be written explicitly as $$ y_h(t)=y_E(t)+C(t)h^a+\text{higher degree terms} $$ In the order estimate at $t=1$ the higher degree terms are disregarded, and 2 values of $h$ are used to eliminate $C(1)$ and compute $a$, 2 equations for 2 unknowns. Then you get exactly the computation you have done, $$ \frac{y_h(1)-y_E(1)}{y_{h/2}(1)-y_E(1)}\approx 2^a $$ from where you get the estimated value of the order $a$.
I get for a larger collection of step sizes the values
If you do the same for the explicit midpoint method (=improved Euler), then conversely the numerical values are better for the larger step sizes, but the order estimate converges slower towards $2$.