The Double Pendulum Map

A double pendulum consists of two connected pendulums, rotating under the force of gravity. This notebook allows you to simulate both simple double pendulums (with point masses at the ends) and compound double pendulums (with mass distributed uniformly along the length of the arms).

Iterating a double pendulum is a matter of stepping four coupled ordinary differential equations (ODE) in time, one for the angular position of each arm and one for the angular velocity. See the appendix for detailed derivations of the equations of motion for both point-mass and compound double pendulums.

Sam Maksimovich recently created a lovely video in which he simultaneously plots all possible double pendulums starting with zero velocity, using color to illustrate their trajectories. The explanation is far better than anything you’ll find here. You should watch it!

At the end he mentions it took six hours to render the video. I’m confident I would not be able to create a lovelier or more effective explanation video, but the visualization is exactly the sort of thing GPUs do very well, so it seemed like it would be fun to plug this into WebGL and make a quick, interactive visualization of the pendulum. A major shortcoming is that WebGL only does single precision, and chaotic simulations definitely benefit from at least double precision, but maybe we’ll see what we can get away with.

The visualization below uses the regl WebGL library to compute and visualize the angle of the of the first (x-axis) and second (y-axis) arms of all double pendulums starting with the specified velocities. This amounts to a two-dimensional slice (just the angular positions) of the four-dimensional phase space (two positions and two velocities).

Toggle between simple (point masses) and compound (distributed mass) pendulums, adjust the initial velocities, and zoom in on regions below to observe the beautiful fractal structure! 🌈

Appendix: Derivations of Equations of Motion

Consider a double pendulum with point masses and at distances and from their respective pivots, with angles and measured from vertical (downward).

Coordinates

The position of mass 1:

The position of mass 2:

Kinetic Energy

Taking time derivatives:

The kinetic energy is:

Potential Energy

Lagrangian

Euler-Lagrange Equations

The Euler-Lagrange equations yield (after simplification):

Generalized Momenta

The generalized momenta are:

In matrix form where:

Inverting to get and computing :

As a first-order system with state :

For a compound pendulum, the mass is distributed along each arm. Consider uniform rods of lengths and with masses and , and moments of inertia and about their pivot points.

Center of Mass Positions

The centers of mass are located at the midpoints:

Kinetic Energy

The kinetic energy includes both translational and rotational components:

For a uniform rod rotating about its end, and . The translational kinetic energies are:

Thus:

Potential Energy

Generalized Momenta

The generalized momenta are:

In matrix form where:

Inverting to get and computing :

As a first-order system with state :