I have a problem with approximating ROC for numerical algorithms for solving ODE's. It's known, that the global error for Euler's method is of order $O(h)$, and for 4th order Runge Kutta it's $O(h^4)$. Using linear regression for log-log correspondence between error and the step size however returns a variety of results for different equations (e.g. pendulum eq or trivial $y'=y$).
Is it a mistake to expect exact (sort of) analytical results for various problems? Should I pick large points for error evaluation instead of choosing e.g. $t = 10$? Or maybe I'm using the wrong formula? I've chosen the one from wikipedia - the $p$ in discretization methods https://en.wikipedia.org/wiki/Rate_of_convergence.
h=1e-7 .. 1e-3
, RK4 for1e-3 .. 1e-1
. – Lutz Lehmann Oct 23 '18 at 10:01t,y = t0, y0; while t+h<tf: t,y = t+h, methodstep(sys,t,y,h);
you need to finish this byt,y = tf, methodstep(sys,t,y,tf-t)
. To avoid almost-zero steps, use something likewhile t+1.01*h<tf:...
– Lutz Lehmann Oct 23 '18 at 21:33