4 ms·
That's about right, but note that both Euler and RK4[1] have the same kind of "whiplash" failure modes when faced with out of band inputs. So RK4 is good, and
by ajross 14y ago
That's about right, but note that both Euler and RK4[1] have the same kind of "whiplash" failure modes when faced with out of band inputs. So RK4 is good, and simple, and worth learning. But as you point out it's really just a performance improvement over naive Euler integration[2].
Basically, don't get hung up over pedantry here. Euler is extremely simple, trivially verifiable and works well in a large number of domains. Demanding everyone who wants to do a simple physics model crack open a textbook is, I think, missing the point.
[1] Fourth order Runge-Kutta integration, a common and reasonably simple algorithm for numeric integration. See: http://en.wikipedia.org/wiki/Runge%E2%80%93Kutta_methods http://en.wikipedia.org/wiki/Runge%E2%80%93Kutta_methods
[2] Euler is the simplest possible integration algorithm most people learn in grade school, essentially: compute your derivatives, multiply by the timestep and add to the current value, and repeat. It falls down and produces wild output when the derivative*timestep product is not small in comparison with the current value.
- bkanber 14y agoThanks! This article and the other Physics in JS article mention that we're using Euler only because it's the easiest for a student to understand. The article also mentions that the next post will be dedicated to exploring the different integration solvers. My guess is that the original commenter just skimmed through the code without reading any of the prose ;)