Project

Hamilton

An interactive phase-space playground for Hamiltonian and Lagrangian systems. Type a system, integrate it with RK4 in a Web Worker, and explore the energy landscape in WebGL2.

ReactTypeScriptWebGL2Web WorkersRunge–Kutta 4Symbolic differentiation

Hamilton is an interactive playground for conservative mechanics. Type a Hamiltonian H(q,p)H(q,p) or a Lagrangian L(q,q˙)L(q,\dot q), choose from 21 built-in systems, and watch the phase-space flow evolve.

Coupled pendulums in Hamiltonian phase space

What it does

  • Supports one or two degrees of freedom, with selectable phase-space projections.
  • Symbolically differentiates the system and compiles the equations of motion to JavaScript.
  • Runs fixed-step RK4 in a Web Worker and renders via WebGL2.
  • Shows an energy heat map, a vector field, live trails and a static phase portrait.
  • Includes a field guide covering phase space, Hamiltonians, Lagrangians, the visual layers and the expression language.

Try it

The live playground is at nikhedonia.net/hamilton. Start with the pendulum to see a separatrix, then try the double pendulum to see chaos.

Read the launch note: Hamilton: A Phase-Space Playground.