Game Development Reference

In-Depth Information

Figure 7-7. A closer look

As you can see from these figures, it's impossible to discern the curves for the improved

Euler and Runge-Kutta methods from the exact solution because they fall almost right

on top of each other. These results clearly show the improvement in accuracy over the

basic Euler method, whose curve is distinct from the other three. Over the interval from

6.5 to 8.5 seconds, the average truncation error is 1.72%, 0.03%, and 3.6×10
−6
% for

Euler's method, the improved Euler method, the Runge-Kutta method, respectively. It

is obvious, based on these results, that for this problem, the Runge-Kutta method yields

substantially better results for a given step size than the other two methods. Of course,

you pay for this accuracy, since you have several more computations per step in the

Runge-Kutta method.

Both of these methods are generally more stable than Euler's method, which is a huge

benefit in real-time applications. Recall our discussion earlier about the stability of Eu‐

ler's method.
Figure 7-5
showed the results of applying Euler's method to an oscillating

dynamical system. There, the motion results that should be sinusoidal were wildly er‐

ratic (i.e., unstable). Applying the improved Euler method, or the Runge-Kutta method,

to the same problem yields stable results, as shown in
Figure 7-8
.