Use stability and convergence tests to explain numerical behavior.
Distinguish local accuracy from long-term energy behavior.
Prerequisites: Linear algebra, ODEs, and earlier lectures in this sequence.
Explicit Euler
For x˙=f(x), explicit Euler uses xk+1=xk+Δtf(xk). Global error is first order under the usual smoothness and fixed-time assumptions. For x˙=λx, the amplification factor is 1+Δtλ, so a decaying continuous system remains stable only inside the method's stability region.
For an undamped oscillator with frequency ω, explicit Euler has eigenvalue magnitudes 1+(ωΔt)2>1. Discrete energy grows while physical energy stays constant.
Semi-implicit Euler
For a separable mechanical system with position-dependent acceleration,
vk+1=vk+Δta(qk),qk+1=qk+Δtvk+1.
This symplectic Euler variant is also first order, but can keep oscillator energy bounded with oscillatory error at a suitable timestep. Generic bounded oscillator motion requires ωΔt<2. At or beyond the boundary, do not expect a reliable trajectory.
With velocity-dependent forces, an engine may treat selected terms implicitly. MuJoCo's integrator named Euler therefore differs in detail from a hand-written explicit Euler method.
Runge–Kutta 4
RK4 samples four slopes:
k1=f(x),k2=f(x+2Δtk1),k3=f(x+2Δtk2),k4=f(x+Δtk3),
then combines them with weights (1,2,2,1)/6. For smooth problems it has fourth-order global accuracy over a fixed interval. Four evaluations cost more than one. RK4 is not generally symplectic and does not exactly conserve energy.
Worked refinement test
Integrate the same smooth problem to the same final time with Δt, Δt/2, and Δt/4. In the asymptotic regime, Euler's error roughly halves and RK4's decreases by about sixteen. Compare to an analytic solution when available. Comparing runs at different final times invalidates the ratio.
The practice uses a unit oscillator with q(0)=1, v(0)=0 and exact solution (cost,−sint). It reports trajectory error and maximum relative energy error.
Practical limits
Contact events can invalidate smooth-order expectations. A stiff spring may force small explicit timesteps even when visible motion is slow. Solver tolerances and floating-point error eventually dominate refinement.
Exercise: Which method is best for a 10-second smooth prediction and which for a very long Hamiltonian simulation? Answer guide: compare accuracy per computation for the first. For the second, investigate geometric structure and long-term energy behavior. Formal order alone does not select a universal winner. Variational integrators appear in the optional post-course extension.
Optimal Control 16-745 — lecture index — Zachary Manchester and CMU course staff. Topic-level connection to discretization, LQR, MPC, trajectory optimization, rotations, and learning.