O'Reilly logo

The Essential Guide to Physics for Flash Games, Animation, and Simulations by Adrian Dobre, Dev Ramtal

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Runge-Kutta integration

Runge-Kutta schemes are more complex than the Euler scheme, but they pay off in terms of considerably greater accuracy. If accuracy is critical for your simulation, you should seriously consider Runge-Kutta. It does come at a performance price, though, especially if you opt for the higher-order schemes. We'll describe two of the most popular Runge-Kutta schemes.

Second-order Runge-Kutta scheme (RK2)

The second-order Runge-Kutta method (RK2) is also known as Heun's method or the improved Euler method. It is a two-stage predictor-corrector method that uses the explicit Euler's method as predictor and a so-called trapezoidal method as corrector. Here are the equations defining the method:

The temporary variables p1, v1

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required