Chaim Ferguson

2022-10-23

Let's say I have solved an ODE with Euler's forward method, and also solved it using RK4, in both cases for varying decreasing step sizes h. Is there any way to look at the graphs and "see" the order of accuracy of the methods?

Yes, graph the differences of the results for stepsizes $h$ and $2h$h as double-logarithmic plot. The graph should be of lines, and the slopes correspond to the order of the method.

More precisely, the numerical result for step size $h$ is in first order of approximation
${y}_{h}={y}_{\ast }+C·{h}^{p}+D/h$
where $C$ accumulates the derivative factors for the method error and $D$ accounts for the floating point errors in the evaluation of every single step.
Thus the mentioned difference gives
${y}_{2h}-{y}_{h}=\left({2}^{p}-1\right)·C·{h}^{p}-D/\left(2h\right)$
so that for moderately small $h\gg \sqrt[p+1]{D/C}$ one gets
$\mathrm{log}\left({y}_{2h}-{y}_{h}\right)\approx \mathrm{log}\left(\left({2}^{p}-1\right)·C\right)+p·\mathrm{log}\left(h\right)$

Do you have a similar question?