Physical Dynamics and Constraints › Worked Example: Two Models of a Pendulum
World Models HandbookAll chapters 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 , angle and angular velocity, with exact dynamics
where is gravitational acceleration and is pendulum length. The first equation is kinematic; the second contains the nonlinear restoring term . For small swings, , while larger swings test behavior beyond that local linearization. With mass fixed to , the physical energy is , measured relative to the lowest point, and the exact unforced flow conserves it. We will fit two models to one simulated trajectory:
- A naive MLP that maps to with no structure at all.
- A Hamiltonian model that learns a scalar Hamiltonian candidate and derives its dynamics from antisymmetric autodiff gradients, with 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 under exact unforced continuous flow; it does not guarantee that equals 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.