Machines of Wonder · 2 of 4

Draw me Huygens' pendulum clock

A damped pendulum, sketched and integrated from one English sentence. You asked Claude. Glyph drew it. The pendulum that gave humanity its first timekeeping accurate enough to navigate by — and that has powered grandfather clocks ever since.

▸ The prompt
"Draw me Christiaan Huygens' pendulum clock. Use the Glyph viz grammar with a 2D trajectory ODE: dθ/dt = ω, dω/dt = −(g/L)·θ − γ·ω, with light damping γ = 0.02 to represent a high-quality mainspring. Integrate over 60 seconds, plot angle vs time. Pencil-sketch style. Beautiful enough for a child to count the swings; deep enough that a horologist recognizes the gentle exponential decay envelope."

— what to say to your AI agent. Claude writes the Glyph spec; the compiler integrates the ODE with RK4 and emits the angle-over-time curve.

A pendulum clock keeping time A pencil-style technical drawing: on the left, a pendulum swings back and forth from a fixed pivot; on the right, an escapement gear with 30 teeth slowly rotates, releasing the pendulum's energy in measured ticks; below, the angle-vs-time trace shows the damped sinusoidal swing. FIG. II. θ(t) — damped harmonic motion
2-second period (g/L = 1) · the envelope decays at γ = 0.02 — about 2 % amplitude lost per swing

Two forces, one rhythm

A pendulum is one of nature's simplest oscillators — two terms in an ODE, no exotic physics. Add a tiny damping term and you've got Huygens' clock; add a periodic kick at the right phase (an escapement) and the pendulum runs forever.

FORCE 1
gravity restores

−(g/L) · θ

The restoring torque is proportional to the displacement angle. For small angles it's linear; the period 2π·√(L/g) depends only on the rod length L and gravity g — not the bob's mass, not the amplitude.

FORCE 2
friction drains

−γ · ω

Air drag, pivot friction, escapement coupling. All combined into a single damping coefficient γ. A good clock keeps γ small — Huygens' first design lost less than a second per day, an order of magnitude better than the verge-and-foliot clocks before it.

THE FIX
escapement adds back

+ε per tick

The mainspring's energy reaches the pendulum through the escapement, which releases a small kick at each extreme. Net energy stays constant; the pendulum keeps a perfect rhythm; the gears advance a precise step each swing.

How Glyph drew it

Claude writes the JSON; Glyph integrates the 2D ODE with 4th-order Runge-Kutta over 1200 samples. Same spec → byte-identical SVG, every platform, every run.

The Glyph spec JSON

// pendulum-clock.json — damped harmonic oscillator
{
  "version": "glyph/0.1",
  "title": "Pendulum clock (Huygens 1656)",
  "data": {
    "trajectory": {
      "shape": "trajectory",
      // dθ/dt = ω (angular velocity)
      "dxdt": "y",
      // dω/dt = −(g/L)·θ − γ·ω
      // with g/L = 1, γ = 0.02
      "dydt": "-x - 0.02*y",
      "initial": { "x": 0.6,
                   "y": 0 },
      "time": { "min": 0,
                "max": 60,
                "samples": 1200 }
    }
  },
  "layers": [{
    "mark": "line",
    "encoding": {
      "x": { "field": "t" },
      "y": { "field": "x" }
    }
  }]
}

14 full swings over 60 seconds, with amplitude shrinking from 0.6 rad to ~0.45 rad — exactly the trajectory the ODE predicts. Try γ = 0 (perfect lossless pendulum), γ = 0.1 (audibly winding down), or γ = 0.5 (overdamped, no oscillation). View on GitHub.

Glyph compiler output SVG

Glyph-rendered damped pendulum trace, byte-locked across CI

Byte-stable across Ubuntu / macOS / Windows × Node 20 / 22. The exponential decay envelope is in the data — no separate "fit" curve drawn; the ODE produces it for free.

Your turn — prompts to try

Damped harmonic motion shows up everywhere — bridges, atoms, springs. Name your system and Claude can pick the ODE.

▸ Phase portrait
"Plot the same damped pendulum in phase space instead of time. x-axis = θ, y-axis = ω. The trajectory should spiral into the origin."
▸ Engineering
"Show me a Tacoma Narrows bridge oscillation — a forced damped harmonic oscillator with a periodic wind force. Find the resonance frequency where the amplitude grows unbounded."
▸ Chemistry
"Plot a Morse potential — the energy curve of a diatomic molecule like H₂. Show how a vibrating molecule is just a damped harmonic oscillator near the equilibrium bond length."
▸ Music
"Draw a plucked guitar string. Damped harmonic motion at the fundamental frequency, plus the first three overtones at integer ratios. Show the composite waveform."

More Machines of Wonder

See all of Life in Glyph ↗ Watt's Steam Engine Wankel Rotor Antikythera