What is the difference between explicit Euler and semi-implicit (symplectic) Euler integration, and why does the update order decide whether an orbit stays closed?
answer
- which velocity moves the position
- old velocity vs freshly updated velocity
- energy grows every step vs stays bounded
- area-preserving update, determinant one
basics
~20 sExplicit Euler moves position with the old velocity; semi-implicit Euler updates velocity first and moves position with the new one. Same cost and order, but the semi-implicit form keeps spring and orbit energy bounded instead of growing every step.
solid answer
~40 sExplicit Euler computes `x += v*dt` and `v += a(x)*dt` from the values at the start of the step. Semi-implicit (symplectic) Euler computes `v += a(x)*dt` first and then `x += v*dt` with the updated velocity. Both are first-order and cost one force evaluation, but on an undamped spring explicit Euler multiplies `v² + ω²x²` by `1 + (ω*dt)²` every step, so an orbit spirals outward and a stiff spring rope rings louder until it explodes. The semi-implicit update preserves phase-space area, so energy only wobbles in a band around the true value while `ω*dt < 2`. Same cost, no systematic energy gain: that is why game physics defaults to it.
code
pseudocode · 9 lines// explicit Euler: both updates read start-of-step values
a = force(x) / m
x = x + v * dt
v = v + a * dt
// semi-implicit (symplectic) Euler: position reads the new velocity
a = force(x) / m
v = v + a * dt
x = x + v * dtgo deeper
Recall the two update orders: explicit Euler moves position with the old velocity, semi-implicit Euler updates velocity first and moves position with the new one.
Explain why the order changes behaviour: show that explicit Euler multiplies a spring's energy by more than one each step, while the semi-implicit update preserves phase-space area.
Recognise energy gain in a shipped simulation as an integrator symptom, separate it from rounding, and know the semi-implicit stability limit of omega times dt below 2.
Treat the integrator as a project-wide default: one structure-preserving method everyone uses, with the stability limit written into how designers may tune spring stiffness.
## What an integrator does inside one step A physics simulation stores, for each body, a **position** `x` and a **velocity** `v`. Every fixed step of length `dt` it computes the **acceleration** `a = F / m` from the forces on the body and must advance `x` and `v` to the end of the step. The exact answer would need the equations of motion integrated over the whole step; an **integrator** approximates that integral from a few samples. The two simplest integrators, explicit and semi-implicit Euler, both sample the force once and both are **first-order**: halve `dt` and the error over a fixed stretch of simulated time roughly halves. They differ in one detail, and that detail decides whether the simulation gains energy. ## Explicit Euler **Explicit (forward) Euler** uses only the values at the start of the step: 1. compute `a = force(x) / m`; 2. `x_new = x + v * dt`; 3. `v_new = v + a * dt`. Position moves with the **old** velocity. Everything on the right-hand side is already known, which is what "explicit" means. ## Semi-implicit (symplectic) Euler **Semi-implicit Euler**, also called **symplectic Euler** or Euler-Cromer, updates velocity first and moves the position with the **new** velocity: 1. compute `a = force(x) / m`; 2. `v_new = v + a * dt`; 3. `x_new = x + v_new * dt`. The cost is identical: one force evaluation and two multiply-adds per component. In code the change is swapping two lines, provided the position line really reads the updated velocity. ## Why the order matters: the spring test Take an undamped spring, `a = -ω² * x`, where `ω` is its angular frequency. Its true energy is proportional to `v² + ω² * x²` and never changes. - **Explicit Euler:** substituting the update gives `v_new² + ω² * x_new² = (1 + (ω*dt)²) * (v² + ω² * x²)`. Energy is multiplied by a factor above one on **every** step, whatever the step length; a shorter step only slows the growth. A 1 Hz spring (`ω` about 6.28 rad/s) on a 1/60 s step gains about 1.1% per step, so its energy nearly doubles every simulated second. - **Semi-implicit Euler:** its update matrix has determinant exactly one, so it preserves **phase-space area**. It conserves a slightly modified energy that differs from the true one by a term proportional to `dt`, so the energy wobbles in a fixed band and does not drift, as long as `ω * dt < 2`. Past that limit it also becomes unstable. | Integrator | Position moved by | Undamped spring over many steps | Force evaluations | |---|---|---|---| | Explicit Euler | velocity at step start | energy grows by `1 + (ω*dt)²` per step | 1 | | Semi-implicit Euler | velocity at step end | energy bounded while `ω*dt < 2` | 1 | ## The orbit that spirals outward A planet on a circular orbit is the same test in two dimensions. With explicit Euler each step moves the planet along its old velocity, which is tangent to the circle, so it always lands slightly farther from the sun; energy rises, the orbit widens and over many revolutions the planet spirals outward. Semi-implicit Euler bends the velocity toward the sun before moving, so the orbit stays closed apart from a slow precession: the error shows up as a phase shift instead of a gain in energy. In a game the same mechanism turns a springy rope or a ragdoll's spring joints into something that rings louder every step until it flies apart. ## Limits of the fix - Semi-implicit Euler is **not more accurate**; it is first-order like explicit Euler. It is preferred because its energy error is bounded rather than cumulative. - The area-preservation argument assumes forces depend on position only. With damping or drag the method is no longer strictly symplectic, but damping removes energy, so it still behaves well within its limits. - It has a **stability limit**: for the stiffest spring in the system, `ω * dt` must stay below 2. Stiff systems need shorter steps or substeps. - The implementation trap is a position update that reads a velocity cached before the velocity update: the code looks semi-implicit and behaves explicitly. Updating position first with the old velocity and then velocity from the force at the **new** position is the other symplectic variant and is also fine.
- Is semi-implicit Euler more accurate than explicit Euler?No. Both are first-order: halving the step roughly halves the error over a fixed time. The difference is structural. Semi-implicit Euler preserves phase-space area, so its error appears as a bounded energy wobble and a slow phase shift, such as an orbit that precesses, rather than steady growth. For accuracy you need a higher-order method or shorter steps; for long-run stability you want the symplectic property.
- Does the symplectic guarantee survive damping and other velocity-dependent forces?Not exactly: the proof assumes forces depend on position only. With drag or damping the update is no longer strictly symplectic, but it still behaves because damping removes energy. The new danger is the damping term itself: integrated explicitly, `v *= (1 - c*dt/m)` flips the velocity's sign every step once `c*dt/m` exceeds 1 and grows without bound once it exceeds 2.
- Semi-implicit Euler is second-order accurate, which is why it is stable.
- Swapping the two update lines cannot matter, since the equations are the same.
- Explicit Euler is fine on an undamped spring if the frame rate is high enough.
- The orbit spirals outward because of floating-point rounding, not the integrator.
- Semi-implicit Euler conserves energy exactly at any step length.