Your browser does not support the HTML5 canvas tag.

Controls

0.00 s

Time integration methods:

Simulating the motion of a physical system means solving its equations of motion, a system of ordinary differential equations (ODEs) that relate positions, velocities and accelerations. Since these equations can generally not be solved analytically, we approximate the solution step by step: given the state (position and velocity) at time $t$, a time integration method computes an approximation of the state at time $t + \Delta t$ using the currently acting forces. Repeating this update for a sequence of small time steps $\Delta t$ advances the simulation over time.

This example shows the motion of a single particle that has an initial velocity and is subject to a constant gravitational acceleration. Because the acceleration is constant here, this special case is one of the rare ones that admits a closed-form solution: $$\begin{align*} \mathbf x(t + \Delta t) &= \mathbf x(t) + \Delta t \mathbf v(t) + \frac12 \Delta t^2 \mathbf a^\text{grav} \\ \mathbf v(t + \Delta t) &= \mathbf v(t) + \Delta t \mathbf a^\text{grav} . \end{align*}$$ This exact trajectory is plotted in green and serves as ground truth against which the numerical solutions (blue), computed with the methods introduced below, can be compared. As soon as forces depend on the state itself in a more complex way — e.g. spring, contact or SPH pressure forces — no analytic solution is available anymore and numerical time integration becomes essential.

Three properties are commonly used to characterize and compare time integration methods:

Try the different methods in the simulation with a large time step (e.g. $\Delta t = 0.1$) and compare how far the blue (numerical) trajectory deviates from the green (exact) one.

Explicit Euler

The explicit Euler method (also called forward Euler) is the simplest time integration scheme for ODEs. It uses only quantities known at the current time $t$ to extrapolate the state to $t + \Delta t$: $$\begin{align*} \mathbf x(t + \Delta t) &= \mathbf x(t) + \Delta t \mathbf v(t) \\ \mathbf v(t + \Delta t) &= \mathbf v(t) + \Delta t \mathbf a(t). \end{align*}$$

Properties:

Symplectic Euler

The symplectic Euler method is also known as semi-implicit Euler: it first updates the velocity using the current acceleration, and then uses this already updated velocity to advance the position: $$\begin{align*} \mathbf v(t + \Delta t) &= \mathbf v(t) + \Delta t \mathbf a(t) \\ \mathbf x(t + \Delta t) &= \mathbf x(t) + \Delta t \mathbf v(t + \Delta t). \end{align*}$$

Properties:

Runge-Kutta 2

Higher-order integration methods are usually formulated for a general first-order ODE $\dot{\mathbf s}(t) = \mathbf f(t, \mathbf s(t))$, where $\mathbf s$ is the state of the system at time $t$. In our example the state consists of the particle's position and velocity, and the ODE is defined by: $$\begin{equation*} \mathbf f(t, \mathbf s(t)) = \begin{pmatrix} \dot{\mathbf x} \\ \dot{\mathbf v} \end{pmatrix} = \begin{pmatrix} \mathbf v(t) \\ \mathbf a(t) \end{pmatrix}, \quad\quad \mathbf s(t) = \begin{pmatrix} \mathbf x(t) \\ \mathbf v(t) \end{pmatrix}. \end{equation*}$$ Using this notation, the second-order Runge-Kutta method (also known as the midpoint method) is defined as: $$\begin{align*} \mathbf k_1 &= \Delta t \, \mathbf f(t, \mathbf s(t)) \\ \mathbf k_2 &= \Delta t \, \mathbf f\!\left(t + \tfrac12 \Delta t,\; \mathbf s(t) + \tfrac12 \mathbf k_1\right) \\ \mathbf s(t + \Delta t) &= \mathbf s(t) + \mathbf k_2. \end{align*}$$ Intuitively, $\mathbf k_1$ is a trial (explicit Euler) step used only to estimate the state at the midpoint $t + \frac12 \Delta t$; the actual step $\mathbf k_2$ is then taken using the derivative evaluated at that midpoint, which cancels out the leading-order error term of the Euler methods.

Properties:

Summary

The following table summarizes the properties discussed above:

MethodOrderForce evals / stepSymplecticTypical use
Explicit Euler11NoBaseline / teaching example
Symplectic Euler11YesDefault for real-time simulation (games, cloth, rigid bodies, SPH, PBD)
Runge-Kutta 222NoHigher short-term accuracy for smooth, non-stiff problems
There is no single "best" method: the right choice depends on whether short-term accuracy, long-term (energy) stability, or per-step cost matters most for the application at hand. Higher-order methods such as Runge-Kutta 4, or implicit methods for stiff problems, extend these same trade-offs further and are covered in later examples.

References