# 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?

Chaim Ferguson 2022-10-23 Answered
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?
You can still ask an expert for help

• Live experts 24/7
• Questions are typically answered in as fast as 30 minutes
• Personalized clear answers

Solve your problem for the price of one coffee

• Math expert for every subject
• Pay only if we can solve it

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)$