# [Fwd: Re: [ODE] Euler vs. Runge-Kutta and adaptive step sizes]

Martin C. Martin martin at metahuman.org
Wed May 1 20:59:02 2002

```Russ sent this just to me, rather than to the list, by mistake, so I'm
forwarding it to the list.

- Martin

-------- Original Message --------
From: Russ Smith <russ@q12.org>
Subject: Re: [ODE] Euler vs. Runge-Kutta and adaptive step sizes
To: "Martin C. Martin" <martin@metahuman.org>

> Russ, I take it you use Euler integration rather than, say, fourth
> order Runge-Kutta?  If so, why?  Would a fourth order Runge-Kutta be a
> lot more work?

you've got to look at what is the real advantage of a higher order
method. if you have an explicit integrator, a higher order method gets
you extra stability. with an implicit integrator this is not so
important. higher order gets you higher accuracy of course, but accuracy
is only important if you are precisely calibrating simulated physics to
a real system, which few people do. higher order will prevent some of
the numerical damping that comes from a low order implicit method,
thereby making the simulated system a bit more predictable. but i think
the best reason to use higher order is to reduce the dependence on step
size. adjusting the step size with a low order method can change the
integrator error markedly, and this can cause problems, e.g. for
adaptive time step methods, or if you take a system tuned at 30 Hz and
run it at 60 Hz.

so, yes a higher order method is more work, but the reason i didn't
implement it right away is that i don't have a need. right now this is
an "exercise left for the reader".

> Also, I'm thinking of implementing my own adaptive step size
> algorithm, step doubling as described in Numerical Recipes.
> Basically, I take a step of a large step size, record the
> positions/velocities of everything, then "rewinding" everything to
> before the step and taking two steps of half the size.  How hard would
> this rewinding be?  Would I simply need to record the linear & angular
> positions & velocities of all the bodies, and all the forces/torques
> I've added to those bodies, then reset them?

yes: the complete system state is the position/orientation/velocity
variables for each body.

> Is there much point in doing this with Euler integration?

errrm ... not sure ... what part of 'numerical recipes' describes this?

--
Russell Smith
http://www.q12.org

```