Physical Dynamics and Constraints › Worked Example: Two Models of a Pendulum

Michael BrenndoerferJune 20, 20262 min read
World Models HandbookAll chapters
Part 4 of 12Space, Physics, and Causality
Chapter 20Physical Dynamics and Constraints › Worked Example: Two Models of a Pendulum
Reading section 8 of 12 · Worked Example: Two Models of a Pendulum · 2 minSection 8 of 12 · 2 min

Book contents

Section 8 of 12 · 2 min read

Physical Dynamics and Constraints › Worked Example: Two Models of a PendulumOne section · Sections in this chapter8 / 12 ↓
Reading tools Definitions & inline links

Choose your expertise level to adjust how many terms are explained. Beginners see more tooltips, experts see fewer to maintain reading flow. Hover over underlined terms for instant definitions.

Article links

Make inline references clickable

Let us make the distinction between structural guarantees and predictive accuracy concrete with an undamped, unit-mass pendulum. Its state is (θ,ω)(\theta, \omega), angle and angular velocity, with exact dynamics

θ˙=ω,ω˙=−glsin⁡θ,\dot{\theta} = \omega, \qquad \dot{\omega} = -\frac{g}{l}\sin\theta,

where gg is gravitational acceleration and ll is pendulum length. The first equation is kinematic; the second contains the nonlinear restoring term sin⁡θ\sin\theta. For small swings, sin⁡θ≈θ\sin\theta\approx\theta, while larger swings test behavior beyond that local linearization. With mass fixed to m=1m=1, the physical energy is Hphys=12l2ω2+gl(1−cos⁡θ)\mathcal{H}_{\text{phys}} = \tfrac{1}{2} l^2 \omega^2 + g l (1 - \cos\theta), measured relative to the lowest point, and the exact unforced flow conserves it. We will fit two models to one simulated trajectory:

  1. A naive MLP that maps (θ,ω)(\theta, \omega) to (θ˙,ω˙)(\dot{\theta}, \dot{\omega}) with no structure at all.
  2. A Hamiltonian model that learns a scalar Hamiltonian candidate Hθ(θ,p)\mathcal{H}_\theta(\theta, p) and derives its dynamics from antisymmetric autodiff gradients, with p=l2ωp = l^2 \omega for unit mass.

This is a controlled illustration, not a general benchmark. Both models train on the exact instantaneous vector field at the same states, and we report the losses rather than assuming equal fit. The Hamiltonian architecture guarantees conservation of its learned Hθ\mathcal{H}_\theta under exact unforced continuous flow; it does not guarantee that Hθ\mathcal{H}_\theta equals Hphys\mathcal{H}_{\text{phys}} or that the predicted trajectory is accurate. The rollout lets us inspect those properties separately for one seed and one held-out initial condition.

We will also demonstrate a simplified bouncing-ball projection: an unconstrained baseline passes through the floor, while the projected update clamps penetration and applies restitution. This enforces unilateral feasibility in the toy discretization but does not solve the full complementarity problem.