Phyein Usul← All simulations English · Deutsch · العربية

Fig. 2 · classical mechanics · chaos

Double Pendulum.

Two rigid rods, two point masses, one gravitational field. Deterministic, and yet a change of a thousandth of a radian in the start sends it somewhere else entirely.

Fig. 2 · double pendulum · RK4, \(h = 1/600\ \mathrm{s}\) t = 0.0 s
Fig. 2b · where the pendulum flips, filmed along a curve through its parameters · computed once on Kaggle, \(\theta_1\) across, \(\theta_2\) up, both −180° … 180° …

Lecture note · Fig. 2 · classical mechanics

The double pendulum: exact laws, unpredictable motion

Numa Koudsie · for readers meeting the subject for the first time, from school to the second year of university

Abstract. Hang one pendulum from the end of another and you get the simplest machine whose future we can write down exactly and still cannot predict. In this note we start from what you can feel in your own arm, build the equations of motion from energy alone with Lagrange's method, solve the case of small swings completely, measure how fast two almost identical starts drift apart, and follow the page as it turns the equations into the moving picture above. Every new word is explained where it first appears, and every result is checked with the page's own numbers in a worked example. Paragraphs marked ★ carry extra mathematics; you can skip them and still follow every later step, because the results they lead to are restated without the star.

01A pendulum on a pendulum

Hold a pen loosely between two fingers and let it swing. That is a pendulum, and since Galileo, four hundred years ago, we have known how to predict where it will be at any moment. Now hang a second pen from the tip of the first, and the easy prediction is gone.

You already own a double pendulum: your arm. Let it hang loose and give it a push from the shoulder. The upper arm turns about the shoulder, the forearm turns about the elbow, and your hand traces a curve that neither joint would draw on its own. You can feel the two parts tugging at each other: when the forearm flicks outward, the upper arm is pulled along, and when the upper arm stops, the forearm keeps going. A gymnast circling the high bar, a nunchaku, and the hook of a crane swinging on its cable are all the same machine: two masses, two rods, and gravity pulling down.

Start the double pendulum with a small push and it rocks gently, mixing two steady rhythms that we will find in section 5. Start it high, as in the simulation above, and the lower arm whips over the top, stops, reverses, and tumbles in a pattern that never seems to repeat. Nothing random is involved. The laws we are about to derive fix the entire future once the starting angles and speeds are given, and the computer follows them so faithfully that in the first twenty seconds the total energy changes by less than one part in ten million. Yet two starts that differ by a thousandth of a radian, about one millimetre at the end of a one-metre rod, end up in completely unrelated places within five seconds.

This pairing of exact laws with practically unpredictable outcomes is called deterministic chaos. "Deterministic" means that the present fixes the future, with no dice thrown. "Chaos" means that the fixing is so delicate that any error in our knowledge of the present grows until it swallows the prediction. The weather behaves in the same way. The air obeys equations we know well, but we can never measure today's atmosphere precisely enough, and forecasts fade after about two weeks.

θ1 θ2 l1 l2 m1 m2 g x y pivot
Figure 1The model. Two point masses \(m_1, m_2\) on rigid, massless rods of lengths \(l_1, l_2\). Each angle is measured from the downward vertical (dashed), counter-clockwise positive. Two numbers, \(\theta_1\) and \(\theta_2\), fix where everything is.

02The model

Physics begins by deciding what to leave out, because a description that keeps everything cannot be solved by anybody. A real pendulum has heavy rods, air pushing on it, friction in its joints, and a wobble out of its plane. We keep only what makes the double pendulum a double pendulum. Each mass is a point mass: all its weight sits at a single point, the way a small heavy ball behaves. Each rod is rigid, so it never stretches, and massless, so it only holds its ball at a fixed distance and carries no weight of its own. Everything moves in one vertical plane, with no friction and no air. Section 9 comes back to what these choices cost.

We describe each rod by its angle from the straight-down direction, the dashed line in Figure 1, counted positive when the rod turns counter-clockwise. Angles are measured in radians. One radian is the angle at which the arc along a circle is exactly as long as the circle's radius, so a full turn is \(2\pi \approx 6.28\) radians and \(1^\circ \approx 0.0175\) radians. Radians are the natural unit for motion on a circle, because the length of an arc is then simply radius times angle.

Now we write down where each ball is. Put the pivot at the origin, with \(x\) pointing right and \(y\) pointing up. The first rod, of length \(l_1\) and tilted by \(\theta_1\), is the long side of a right triangle: its sideways part is \(l_1\sin\theta_1\) and its downward part is \(l_1\cos\theta_1\). Because \(y\) points up and the ball hangs below the pivot, its height is negative. The second rod starts where the first one ends, so for the second ball we add its own sideways and downward parts:

\[ \begin{aligned} x_1 &= l_1\sin\theta_1, & y_1 &= -l_1\cos\theta_1, \\ x_2 &= x_1 + l_2\sin\theta_2, & y_2 &= y_1 - l_2\cos\theta_2 . \end{aligned} \tag{1} \]

We can test (1) against intuition. At \(\theta_1 = 0\) the first ball hangs straight down at \(y_1 = -l_1\); at \(\theta_1 = 90^\circ\) it sticks straight out sideways, at \(x_1 = l_1\), \(y_1 = 0\). Two angles fix the shape completely, so the system has two degrees of freedom, two independent ways to move.

Knowing where the balls are is not enough to know where they go next: a ball at the bottom of its swing could be at rest or rushing through. We also need how fast each angle is changing, the angular velocity \(\omega_i = \mathrm{d}\theta_i/\mathrm{d}t\), measured in radians per second, and later the rate at which that changes, the angular acceleration \(\alpha_i = \mathrm{d}\omega_i/\mathrm{d}t = \ddot\theta_i\). Throughout this note a dot over a letter means its rate of change in time. The four numbers \((\theta_1, \theta_2, \omega_1, \omega_2)\) together are the state: hand them to the laws of motion and the whole future follows. On the page the upper ball and rod are fixed at \(m_1 = 1\ \mathrm{kg}\) and \(l_1 = 1\ \mathrm{m}\), gravity is \(g = 9.81\ \mathrm{m/s^2}\), and the sliders set the lower ball's mass and rod as multiples of the upper ones, \(m_2/m_1\) and \(l_2/l_1\). The default start is \(\theta_1 = 120^\circ\), \(\theta_2 = 150^\circ\), both at rest, with equal masses and lengths.

03Energy

The obvious way to find the motion is Newton's: add up the forces on each ball and set force equal to mass times acceleration. For the double pendulum this is hard work, because each rod pulls or pushes on its balls with a force we do not know in advance. That force changes in strength and direction at every instant, and it is always exactly as large as it must be to keep the rod's length fixed. There is a cleverer road that never needs these rod forces. It goes through energy, of which there are two kinds here: the energy of motion and the energy of height.

3.1How fast the balls move

Velocity is the rate of change of position, so we take the time derivative of each line of (1). The lengths never change; only the angles do. When an angle changes at the rate \(\omega\), the chain rule says that \(\sin\theta\) changes at the rate \(\omega\cos\theta\) and \(\cos\theta\) at the rate \(-\omega\sin\theta\). Therefore

\[ \begin{aligned} \dot x_1 &= l_1\omega_1\cos\theta_1, & \dot y_1 &= l_1\omega_1\sin\theta_1, \\ \dot x_2 &= \dot x_1 + l_2\omega_2\cos\theta_2, & \dot y_2 &= \dot y_1 + l_2\omega_2\sin\theta_2 . \end{aligned} \tag{2} \]

The speed follows from Pythagoras, \(v^2 = \dot x^2 + \dot y^2\). For the upper ball, \(v_1^2 = l_1^2\omega_1^2(\cos^2\theta_1 + \sin^2\theta_1) = l_1^2\omega_1^2\). This is what we expect: a ball on a rod of length \(l_1\) turning at \(\omega_1\) runs along its circle at the speed \(l_1\omega_1\). For the lower ball, squaring and adding gives one term for each rod and a mixed term from the two together:

\[ \begin{aligned} v_2^2 &= l_1^2\omega_1^2 + l_2^2\omega_2^2 + 2\,l_1 l_2\,\omega_1\omega_2\left(\cos\theta_1\cos\theta_2 + \sin\theta_1\sin\theta_2\right) \\ &= l_1^2\omega_1^2 + l_2^2\omega_2^2 + 2\,l_1 l_2\,\omega_1\omega_2\cos\varphi , \qquad \varphi \equiv \theta_1 - \theta_2 . \end{aligned} \]

In the second line the bracket has collapsed by the angle-difference rule of trigonometry, \(\cos a\cos b + \sin a\sin b = \cos(a-b)\). The new symbol \(\varphi = \theta_1 - \theta_2\) is the angle between the two rods; it will appear again and again.

3.2The two energies

The kinetic energy of a ball, the energy it has because it moves, is \(\tfrac12 m v^2\). It equals the work needed to bring the ball from rest up to the speed \(v\), and you feel it as the sting when a fast ball lands in your hand. For both balls together,

\[ T = \tfrac12 m_1 l_1^2\omega_1^2 + \tfrac12 m_2\left[\, l_1^2\omega_1^2 + l_2^2\omega_2^2 + 2\,l_1 l_2\,\omega_1\omega_2\cos\varphi \right]. \tag{3} \]

The potential energy is energy stored in height. Lifting a mass \(m\) through a height \(\Delta y\) costs the work \(m g\,\Delta y\), and the mass gives that work back when it falls. Measuring heights from the pivot, each ball has potential energy \(mgy\), negative because the balls hang below the pivot. Only differences of potential energy ever matter, so the choice of zero is ours. From (1),

\[ V = m_1 g y_1 + m_2 g y_2 = -(m_1+m_2)\,g\,l_1\cos\theta_1 - m_2\,g\,l_2\cos\theta_2 . \tag{4} \]

Note the factor \(m_1 + m_2\) in the first term. When the upper rod tilts, it lifts not only its own ball but the whole lower pendulum with it.

The last term in (3) carries the whole story of the coupling. The lower ball rides on the upper one, the way a passenger walking down the aisle rides on a moving train: its velocity is its own velocity plus the train's. When the two rods point the same way and turn the same way, \(\cos\varphi = 1\) and the speeds simply add, \(v_2 = l_1\omega_1 + l_2\omega_2\), like walking forward in a forward-moving train. When the rods are at right angles, \(\cos\varphi = 0\), and the two speeds add like the two short sides of a right triangle. Because the rods' directions keep changing, the way the two motions combine keeps changing too. That is the mathematical form of what you felt in your arm: each rod is forever pushing and pulling on the other.

Example 3.1 · the energy of the default start

The default start has both balls at rest, so \(T = 0\), and \(\theta_1 = 120^\circ\), \(\theta_2 = 150^\circ\) with \(m_1 = m_2 = 1\ \mathrm{kg}\) and \(l_1 = l_2 = 1\ \mathrm{m}\). Equation (4) gives \(V = -2\times 9.81\times\cos 120^\circ - 9.81\times\cos 150^\circ = 9.81 + 8.50 = 18.31\ \mathrm{J}\). Hanging straight down, the pendulum would have \(V = -3\times 9.81 = -29.43\ \mathrm{J}\), so the default start carries \(47.7\ \mathrm{J}\) more than the resting pendulum. Standing the whole pendulum on its head, both rods straight up, would need \(V = +29.43\ \mathrm{J}\), more than the \(18.31\ \mathrm{J}\) available, so the upper rod can never reach the top. The lower rod alone, though, can swing over the top while the upper one hangs low: with \(\theta_1 = 0\) and \(\theta_2 = 180^\circ\), \(V = -19.62 + 9.81 = -9.81\ \mathrm{J}\), well within reach. This is exactly what you see on the page: the lower arm flips over again and again, the upper arm never does.

Energy is conserved

There is no friction and no air in the model, so the total energy \(E = T + V\) never changes: the pendulum can only trade height for speed and back, like a ball rolling up and down the sides of a valley. Gravity changes the speeds, but only by taking from the height or giving to it. The rods do no net work. The upper rod pulls its ball towards the pivot, at right angles to the ball's circular path, so it neither speeds the ball up nor slows it down. The lower rod is subtler: it can push the upper ball forward and the lower ball back, or the other way round, and so it does work on each ball separately. But because its length cannot change, both ends of it move along the rod at the same rate, and the work it does on one ball is exactly the work it takes from the other, like a rigid pole held between two skaters. Section 4.5 gives the formal proof. This conservation gives the simulation a built-in check: the Drift readout above shows how far the computed energy wanders from its starting value, and any wandering is an error of the computation, never of the physics.

04From energy to motion

We now have the two energies. To get from them to the motion without ever meeting the unknown rod forces, we use the method found by Lagrange in the 1780s and given its deepest form by Hamilton in the 1830s. Form the difference of the two energies, the Lagrangian \(L = T - V\). Imagine every conceivable way the two angles could get from a given starting shape to a given final shape in a given time: the real path, and also all the wrong ones that dawdle, rush or wobble. For each path, add up \(L\) moment by moment; this total, \(S = \int L\,\mathrm{d}t\), is called the action of the path. Hamilton's principle states that the path nature takes is the one whose action does not change, to first order, when the path is bent slightly. It is like standing at the bottom of a valley: take one small step to the side and your height does not change at first. The rod forces never enter, because, as we saw in the box on energy, they do no net work on any motion the rods allow.

4.1The Euler–Lagrange equation ★

We turn the principle into an equation. Take the true path and bend one angle by a tiny amount \(\delta\theta_i(t)\), a small wiggle that is zero at the start and at the end, because the start and end shapes are fixed. (Here, and only here, \(\delta\) means "a small change of".) The angular velocity then changes by the rate of change of the wiggle, \(\delta\omega_i = \mathrm{d}(\delta\theta_i)/\mathrm{d}t\). To first order the action changes by how fast \(L\) responds to each change, times the change:

\[ \delta S = \int \left[ \frac{\partial L}{\partial\theta_i}\,\delta\theta_i + \frac{\partial L}{\partial\omega_i}\,\frac{\mathrm{d}(\delta\theta_i)}{\mathrm{d}t} \right]\mathrm{d}t . \]

The second term contains the rate of change of the wiggle rather than the wiggle itself. Integration by parts, the product rule read backwards, moves the time derivative from the wiggle onto the other factor, at the price of a minus sign and a boundary term. The boundary term is zero because the wiggle vanishes at both ends, and what remains is the wiggle multiplied by a single bracket:

\[ \delta S = \int \left[ \frac{\partial L}{\partial\theta_i} - \frac{\mathrm{d}}{\mathrm{d}t}\frac{\partial L}{\partial\omega_i} \right] \delta\theta_i\,\mathrm{d}t . \]

This must be zero for every possible wiggle. If the bracket were positive at some moment, we could choose a wiggle that is positive just there and zero everywhere else, and the action would change. So the bracket itself must vanish at every moment.

Key result · the Euler–Lagrange equation \[ \frac{\mathrm{d}}{\mathrm{d}t}\frac{\partial L}{\partial\omega_i} - \frac{\partial L}{\partial\theta_i} = 0 , \qquad i = 1, 2. \tag{5} \]

There is one such equation for each angle. Read it as Newton's second law in disguise: the quantity \(p_i = \partial L/\partial\omega_i\), called the generalised momentum of \(\theta_i\), changes at the rate \(\partial L/\partial\theta_i\), which plays the part of a force.

For the upper angle the generalised momentum is

\[ p_1 = \frac{\partial L}{\partial\omega_1} = (m_1+m_2)\,l_1^2\,\omega_1 + m_2 l_1 l_2\,\omega_2\cos\varphi . \]

This is an angular momentum about the pivot, but not simply \(m_1 l_1^2\omega_1\): it already contains the lower ball, because when the upper rod turns, it carries the lower ball along.

4.2The equation for the upper angle

Two kinds of derivative meet in (5), and we must keep them apart. A partial derivative such as \(\partial L/\partial\omega_1\) treats \(L\) as a function of four separate numbers \(\theta_1, \theta_2, \omega_1, \omega_2\) and asks how \(L\) changes when one of them alone is changed, the other three held still. The time derivative \(\mathrm{d}/\mathrm{d}t\) then follows the actual motion, in which all four change together. In particular the chain rule gives \(\tfrac{\mathrm{d}}{\mathrm{d}t}\cos\varphi = -\sin\varphi\,(\omega_1-\omega_2)\). The three pieces of (5) for the upper angle are

\[ \begin{aligned} \frac{\partial L}{\partial\omega_1} &= (m_1+m_2)\,l_1^2\,\omega_1 + m_2 l_1 l_2\,\omega_2\cos\varphi, \\ \frac{\mathrm{d}}{\mathrm{d}t}\frac{\partial L}{\partial\omega_1} &= (m_1+m_2)\,l_1^2\,\alpha_1 + m_2 l_1 l_2\,\alpha_2\cos\varphi - m_2 l_1 l_2\,\omega_2(\omega_1-\omega_2)\sin\varphi, \\ \frac{\partial L}{\partial\theta_1} &= -m_2 l_1 l_2\,\omega_1\omega_2\sin\varphi - (m_1+m_2)\,g\,l_1\sin\theta_1 . \end{aligned} \]

In the third line the first term comes from \(T\), where \(\theta_1\) hides inside \(\cos\varphi\), and the second from \(-V\). Subtracting the third line from the second, as (5) requires, the two terms containing \(\omega_1\omega_2\) cancel exactly, and dividing by \(l_1\) leaves

\[ (m_1+m_2)\,l_1\,\alpha_1 + m_2 l_2\,\alpha_2\cos\varphi = -m_2 l_2\,\omega_2^2\sin\varphi - (m_1+m_2)\,g\sin\theta_1 . \tag{6} \]

Every term has a meaning you can feel. On the right, \(-(m_1+m_2)g\sin\theta_1\) is gravity pulling the whole tilted pendulum back towards the bottom, harder the further it is from straight down. The term with \(\omega_2^2\) is the lower ball circling round the elbow and tugging outward on the end of the upper rod, the same tug you feel in your hand when you whirl a stone on a string. On the left, the term with \(\alpha_2\) says that whenever the lower arm speeds up or slows down, it jerks the upper arm.

4.3The equation for the lower angle

We repeat the same three steps for \(\theta_2\). Now \(\theta_2\) sits inside \(\cos\varphi\) with a minus sign, because \(\varphi = \theta_1 - \theta_2\), so \(\partial\cos\varphi/\partial\theta_2 = +\sin\varphi\):

\[ \begin{aligned} \frac{\partial L}{\partial\omega_2} &= m_2 l_2^2\,\omega_2 + m_2 l_1 l_2\,\omega_1\cos\varphi, \\ \frac{\mathrm{d}}{\mathrm{d}t}\frac{\partial L}{\partial\omega_2} &= m_2 l_2^2\,\alpha_2 + m_2 l_1 l_2\,\alpha_1\cos\varphi - m_2 l_1 l_2\,\omega_1(\omega_1-\omega_2)\sin\varphi, \\ \frac{\partial L}{\partial\theta_2} &= m_2 l_1 l_2\,\omega_1\omega_2\sin\varphi - m_2\,g\,l_2\sin\theta_2 . \end{aligned} \]

Subtracting, the \(\omega_1\omega_2\) terms cancel once more, and dividing by \(m_2 l_2\) leaves

\[ l_1\,\alpha_1\cos\varphi + l_2\,\alpha_2 = l_1\,\omega_1^2\sin\varphi - g\sin\theta_2 . \tag{7} \]

The lower arm feels gravity, \(-g\sin\theta_2\), and the outward tug of the upper ball's circling, \(l_1\omega_1^2\sin\varphi\), which reaches it through the elbow.

4.4Solving for the accelerations

Each of (6) and (7) contains both accelerations, because each rod pushes on the other. A computer stepping forward in time needs each acceleration on its own, so we treat (6) and (7) as two linear equations for the two unknowns \(\alpha_1, \alpha_2\). In matrix form,

\[ \begin{pmatrix} (m_1+m_2)\,l_1 & m_2 l_2\cos\varphi \\ l_1\cos\varphi & l_2 \end{pmatrix} \begin{pmatrix} \alpha_1 \\ \alpha_2 \end{pmatrix} = \begin{pmatrix} b_1 \\ b_2 \end{pmatrix}, \qquad \begin{aligned} b_1 &= -m_2 l_2\,\omega_2^2\sin\varphi - (m_1+m_2)\,g\sin\theta_1, \\ b_2 &= l_1\,\omega_1^2\sin\varphi - g\sin\theta_2 . \end{aligned} \tag{8} \]

The determinant of the matrix is the product of its diagonal entries minus the product of the other two:

\[ D = (m_1+m_2)\,l_1 l_2 - m_2 l_1 l_2\cos^2\varphi = l_1 l_2\,(m_1 + m_2\sin^2\varphi) , \]

using \(1-\cos^2\varphi = \sin^2\varphi\). It is always positive, because \(m_1\) is. A non-zero determinant means the two equations never contradict each other and never say the same thing twice, so there is always exactly one answer. Cramer's rule writes it down: each unknown is a ratio whose denominator is \(D\) and whose numerator is the determinant of the matrix with that unknown's column replaced by the right-hand side,

\[ \alpha_1 = \frac{b_1\,l_2 - m_2 l_2\cos\varphi\;b_2}{D}, \qquad \alpha_2 = \frac{(m_1+m_2)\,l_1\,b_2 - l_1\cos\varphi\;b_1}{D} . \]

★ The page computes the same two numbers in a tidier form. Multiply numerator and denominator by 2 and use \(2\sin^2\varphi = 1-\cos 2\varphi\) in the denominator. In the numerator of \(\alpha_1\), use \(2\sin\theta_2\cos\varphi = \sin\theta_1 - \sin(\theta_1 - 2\theta_2)\); in the numerator of \(\alpha_2\), use \(\sin\theta_1\cos\varphi - \sin\theta_2 = \cos\theta_1\sin\varphi\), which follows from expanding \(\sin\theta_2 = \sin(\theta_1 - \varphi)\) and is where the common factor \(\sin\varphi\) of \(\alpha_2\) comes from. The result is

Key result · the equations of motion, as the page computes them \[ \begin{aligned} \alpha_1 &= \frac{\begin{gathered} -g\,(2m_1+m_2)\sin\theta_1 - m_2\,g\sin(\theta_1-2\theta_2) \\ {} - 2\,m_2\sin\varphi\,\left(\omega_2^2\,l_2 + \omega_1^2\,l_1\cos\varphi\right) \end{gathered}}{l_1\,(2m_1+m_2-m_2\cos 2\varphi)}, \\[4pt] \alpha_2 &= \frac{\begin{gathered} 2\sin\varphi\,\bigl(\omega_1^2\,l_1\,(m_1+m_2) + g\,(m_1+m_2)\cos\theta_1 \\ {} + \omega_2^2\,l_2\,m_2\cos\varphi\bigr) \end{gathered}}{l_2\,(2m_1+m_2-m_2\cos 2\varphi)} . \end{aligned} \tag{9} \]

Given the state \((\theta_1, \theta_2, \omega_1, \omega_2)\) at any moment, (9) gives the two angular accelerations at that moment. Everything that follows uses only this.

Checked against a direct numerical solve of (8) at 10 000 random states and parameter values: the two agree to rounding error, about one part in \(10^{13}\).

A long formula deserves suspicion, and physicists have two quick tests for it. The first is units. An angular acceleration has units of \(1/\mathrm{s^2}\), so every term of (9) must too, and it does: \(g\) divided by a length gives \(1/\mathrm{s^2}\), \(\omega^2 l\) divided by a length gives \(1/\mathrm{s^2}\), and the masses appear above and below the fraction line and cancel. The second test is an extreme case whose answer we already know. Make the lower ball so light that it hardly exists, \(m_2 \to 0\). The upper arm then carries nothing and must swing like an ordinary single pendulum. Setting \(m_2 = 0\) in (9), every term with \(m_2\) drops out, the numerator of \(\alpha_1\) becomes \(-2m_1 g\sin\theta_1\), the denominator becomes \(2m_1 l_1\), and \(\alpha_1 = -(g/l_1)\sin\theta_1\), exactly the law of a simple pendulum of length \(l_1\). A formula that failed either test would be wrong somewhere; this one passes both.

4.5Why the energy is conserved ★

The box in section 3 argued from the rods. Lagrange's method gives a shorter proof. Define the quantity \(\mathcal{E} = \sum_i \omega_i\,\partial L/\partial\omega_i - L\). Differentiating it in time and using (5) to replace \(\tfrac{\mathrm{d}}{\mathrm{d}t}\,\partial L/\partial\omega_i\) by \(\partial L/\partial\theta_i\), every term cancels except \(-\partial L/\partial t\), the part of the change of \(L\) that comes from the clock itself. Our \(L\) does not contain the time explicitly, so \(\mathcal{E}\) is constant. Every term of \(T\) contains exactly two angular velocities, so \(\sum_i \omega_i\,\partial T/\partial\omega_i = 2T\), while \(V\) contains none. Hence \(\mathcal{E} = 2T - (T - V) = T + V\): the conserved quantity is the total energy.

05Small swings: two normal modes

Equations (9) are too tangled to solve with pencil and paper. Before handing them to the computer, we look at the one case we can solve completely: gentle swings. When an angle is small, its sine is almost equal to the angle itself in radians. At \(10^\circ\), for example, \(\theta = 0.1745\) and \(\sin\theta = 0.1736\), half a percent apart. In the same way \(\cos\varphi \approx 1\), and the terms with \(\omega^2\) are products of two small quantities, far smaller than the rest, so we drop them. With equal masses \(m\) and equal lengths \(l\), and writing \(\ddot\theta_i\) for \(\alpha_i\), equation (6) divided by \(ml\) becomes \(2\ddot\theta_1 + \ddot\theta_2 = -2(g/l)\,\theta_1\), and (7) divided by \(l\) becomes \(\ddot\theta_1 + \ddot\theta_2 = -(g/l)\,\theta_2\). In matrix form,

\[ \begin{pmatrix} 2 & 1 \\ 1 & 1 \end{pmatrix} \begin{pmatrix} \ddot\theta_1 \\ \ddot\theta_2 \end{pmatrix} = -\frac{g}{l} \begin{pmatrix} 2 & 0 \\ 0 & 1 \end{pmatrix} \begin{pmatrix} \theta_1 \\ \theta_2 \end{pmatrix} . \tag{10} \]

These equations are linear: the angles appear only to the first power. For linear equations, the sum of two solutions is again a solution, so we can look for the simplest solutions first and build every other small motion out of them. A single pendulum swings as \(\cos\Omega t\), so we try the same for both arms together, swinging at one common angular frequency \(\Omega\) with fixed sizes \(u_1, u_2\): \(\theta_i = u_i\cos\Omega t\). (We write \(\Omega\) for this frequency to keep it apart from the angular velocities \(\omega_i\).) Each second derivative brings down a factor \(-\Omega^2\), and (10) becomes

\[ \Bigl[\tfrac gl\begin{pmatrix}2&0\\0&1\end{pmatrix} - \Omega^2\begin{pmatrix}2&1\\1&1\end{pmatrix}\Bigr]\begin{pmatrix}u_1\\u_2\end{pmatrix} = 0 . \]

This always has the trivial solution \(u_1 = u_2 = 0\), the pendulum hanging still. It has a non-trivial solution only if its two equations say the same thing, which happens exactly when the determinant of the bracket is zero:

\[ 2\left(\tfrac gl - \Omega^2\right)^2 - \Omega^4 = 0 \quad\Longrightarrow\quad \tfrac gl - \Omega^2 = \pm\frac{\Omega^2}{\sqrt2} \quad\Longrightarrow\quad \Omega^2 = \frac{g/l}{1 \pm 1/\sqrt2} . \]

Multiplying numerator and denominator by \(\sqrt2(\sqrt2 \mp 1)\), the denominator becomes \((\sqrt2 \pm 1)(\sqrt2 \mp 1) = 1\), and we obtain

Key result · the two normal-mode frequencies \[ \Omega_\mp^2 = \left(2\mp\sqrt2\right)\frac{g}{l}, \quad \Omega_- = 2.40\ \mathrm{rad/s},\quad \Omega_+ = 5.79\ \mathrm{rad/s} \;\; (l = 1\ \mathrm{m}). \tag{11} \]

Each frequency comes with its own shape of motion, fixed by the first row of the bracket: \(u_2/u_1 = 2\,(g/l-\Omega^2)/\Omega^2\). For the slow frequency this ratio is \(+\sqrt2 \approx 1.41\): both arms swing the same way, the lower one about 1.4 times as far, and the pendulum moves almost as one piece. For the fast frequency it is \(-\sqrt2\): the arms swing against each other, the elbow going one way while the hand goes the other (Figure 2). These two motions are the normal modes of the pendulum, the two ways it can swing in which every part keeps step with every other at a single frequency. Any small motion is a mixture of the two. The ratio of the frequencies is \(\Omega_+/\Omega_- = 1 + \sqrt2 \approx 2.41\), an irrational number, so the mixture never repeats exactly; yet it stays perfectly regular and perfectly predictable. There is no chaos in small swings.

slow mode ω− = 2.40 rad/s period 2.62 s arms together, u2 / u1 = +√2 fast mode ω+ = 5.79 rad/s period 1.09 s arms opposed, u2 / u1 = −√2
Figure 2The two normal modes for equal masses and \(l = 1\ \mathrm{m}\), with the angles exaggerated so they can be seen. Dark: one turning point; pale: the opposite turning point half a period later.
Example 5.1 · the two periods

The period of a swing is the time for one full cycle, \(2\pi/\Omega\). For the page's equal rods of \(1\ \mathrm{m}\), the slow mode has period \(2\pi/2.397\ \mathrm{s} = 2.62\ \mathrm{s}\) and the fast mode \(2\pi/5.787\ \mathrm{s} = 1.09\ \mathrm{s}\). For comparison, a single pendulum of length \(1\ \mathrm{m}\) has period \(2\pi\sqrt{l/g} = 2.01\ \mathrm{s}\). Hanging a second pendulum below it splits that one rhythm into a slower one and a faster one.

Exercise 5.1 · on the figure above

Keep both ratio sliders at 1 and both angular velocities at 0. Set \(\theta_1 = 5^\circ\) and \(\theta_2 = 7^\circ\), close to \(\sqrt2\times 5^\circ\): the pendulum swings almost as one piece, with a period near 2.6 s. Now set \(\theta_2 = -7^\circ\): the arms swing against each other, twice as fast as before and a little more. Time ten swings of each and compare with (11).

06Chaos

At larger angles the small-angle shortcut breaks down. The sines can no longer be replaced by the angles, and the \(\omega^2\) terms, the outward tugs of the circling balls, become as strong as gravity. Some starts then move chaotically. We recognise chaos not by how wild the motion looks, but by a precise test: sensitive dependence on the starting state. Start two pendulums whose upper angles differ by \(0.001\ \mathrm{rad}\), about one millimetre at the end of a one-metre rod, and follow the distance \(d(t)\) between their lower balls. Figure 3 shows this distance for a gentle start and a wild start, computed with the same equations and the same time step as the page.

10⁻⁴ 10⁻³ 10⁻² 10⁻¹ 10⁰ 10¹ 0 2 4 6 8 10 12 14 16 18 20 time t (s) distance between the two lower masses (m) start 10°, 10° (low energy) start 120°, 150° (high energy)
Figure 3Distance between the lower masses of two pendulums whose upper angles start \(0.001\ \mathrm{rad}\) apart, on a logarithmic scale. Equal masses and lengths, both at rest at the start, RK4 with \(h = 1/600\ \mathrm{s}\). At low energy the distance stays below about 1.5 mm for the whole 20 s. At high energy it grows like a straight line on this scale, which means exponentially, until it is as large as the pendulum itself.

The vertical scale of Figure 3 is logarithmic: each step up multiplies the distance by ten. On such a scale anything that grows by the same factor every second, like money earning compound interest, climbs as a straight line. In small swings the equations are linear, so the difference between two motions is itself a small swing and keeps its size: the low-energy curve rises and falls in arches but never grows. In large swings the lower arm is carried again and again to near the top, where it balances like a pencil standing on its tip. A hair's difference then decides whether it tips over or falls back, and once the two pendulums choose differently, they are on different roads. Each such moment magnifies the gap. Measured with the page's own equations for the default start, the gap grows almost twice as fast while the lower rod is more than \(120^\circ\) from straight down as at other times.

A straight line on a logarithmic scale means exponential growth, \(d(t) \approx d_0\,e^{\lambda t}\), where \(d_0\) is the starting distance and \(\lambda\) (lambda) is the growth rate per second. For the high-energy start of Figure 3 the curve wobbles, but a straight line laid through it, up to the moment the distance reaches \(0.1\ \mathrm{m}\) after \(4.1\ \mathrm{s}\), gives \(\lambda \approx 1.4\) per second: the distance doubles roughly every half second. The careful way to measure \(\lambda\) follows a tiny change of the whole state, both angles and both angular velocities, shrinks it back whenever it has grown, and averages the logarithm of its growth over a very long time. The limit of that average is the largest Lyapunov exponent, named after the Russian mathematician Aleksandr Lyapunov:

\[ \lambda = \lim_{t\to\infty}\ \lim_{d_0\to 0}\ \frac{1}{t}\,\ln\frac{d(t)}{d_0} . \tag{12} \]

Here \(d\) is the distance between the two states, treating angles in radians and angular velocities in radians per second as plain numbers. Any other reasonable choice of distance gives the same \(\lambda\), because \(\lambda\) measures a rate of growth, not a size. The order of the two limits matters: first the starting difference is made vanishingly small, so that we measure the growth of truly tiny differences, and only then is the time made long. Done in full for the default start, with the page's equations and step, shrinking the change back every \(0.1\ \mathrm{s}\) over \(20\,000\ \mathrm{s}\) of motion, (12) gives \(\lambda \approx 1.46\) per second. The 1.4 read off Figure 3, from one stretch of time and two of the four coordinates, was not far off.

Example 6.1 · the price of prediction

With \(\lambda = 1.46\) per second, an error in the starting state is multiplied by \(e^{1.46} \approx 4.3\) every second. To predict ten seconds further with the same final accuracy, we must therefore know the start \(e^{14.6} \approx 2\times10^{6}\) times more precisely. A starting error of one millimetre would have to shrink to about half a nanometre, the width of a few atoms. This is why no computer, however fast, can follow the double pendulum for long: the limit is our knowledge of the start, not the arithmetic.

Chaos is not noise, since nothing random enters, and it is not a failure of energy conservation: the energy stays fixed while the motion wanders over much of what that energy allows. For the same reason, a small energy drift in the computer proves no more than itself. Countless different paths share the same energy, so a drift of a few parts in \(10^{8}\) shows that the computation is sound, not that its positions are the true ones beyond the horizon of predictability.

Exercise 6.1 · on the figure above

Switch on the Chaos twin, a second pendulum started with \(\theta_1\) larger by \(0.001\ \mathrm{rad}\). From \(10^\circ, 10^\circ\) its separation readout stays near \(10^{-3}\ \mathrm{m}\). From \(120^\circ, 150^\circ\) the pale twin peels away within a few seconds. Find the smallest starting angles at which you can see the two pendulums separate within 20 s.

07Solving it step by step

Equations (9) give the accelerations in any state, but no formula gives the angles at a later time directly. The computer therefore does what a hiker does in fog: it looks at the slope where it stands, takes a small step, and looks again. We write the state as \(s = (\theta_1,\theta_2,\omega_1,\omega_2)\) and the laws of motion as \(\mathrm{d}s/\mathrm{d}t = F(s) = (\omega_1,\omega_2,\alpha_1,\alpha_2)\): the angles change at the angular velocities, and the angular velocities change at the accelerations (9). The simplest walk, Euler's method, takes \(s(t+h) = s + h\,F(s)\) for a small time step \(h\). It is easy to understand and poor in practice, because it uses the slope only at the start of each step, and on a curving path that slope is already wrong halfway along. Applied to a pendulum, Euler's method makes the swing grow a little on every step, as if someone were secretly pushing it.

The fourth-order Runge–Kutta method, RK4 for short, looks at the slope four times per step: once at the start, twice at the middle (each time using the best estimate so far), and once at the end. It then takes a weighted average:

\[ \begin{aligned} k_1 &= F(s), & k_2 &= F\!\left(s + \tfrac{h}{2}k_1\right), \\ k_3 &= F\!\left(s + \tfrac{h}{2}k_2\right), & k_4 &= F(s + h\,k_3), \\ s(t+h) &= s + \tfrac{h}{6}\left(k_1 + 2k_2 + 2k_3 + k_4\right). \end{aligned} \tag{13} \]

If the slope depended on time alone, the two middle looks would agree and the weights would become 1, 4, 1, the weights of Simpson's rule for the area under a curve. RK4 is the generalisation of Simpson's rule to a slope that also depends on where we are. The error it makes in one step shrinks like \(h^5\), and the error piled up over a fixed stretch of time like \(h^4\), so halving the step makes the computed path about sixteen times more accurate. The energy error, which the Drift readout shows, shrinks even faster here: in tests with the page's own code, halving the step from \(1/600\ \mathrm{s}\) reduced the drift after a minute about 35 times, and halving again about 25 times. The page uses \(h = 1/600\ \mathrm{s}\). On a screen that draws sixty pictures a second, this fits exactly ten steps into each picture, and it keeps the energy drift of the default start below one part in ten million over twenty seconds, far below anything you could see.

Each picture advances the motion by the real time that has passed, multiplied by the Time scale slider, in steps of \(h\). A single picture never counts for more than \(0.05\ \mathrm{s}\), and the Time scale never exceeds 1.5, so at most 45 steps are taken for one picture; the safety limit of 600 steps in the code is never reached. Moving a mass, length, angle or angular-velocity slider restarts the motion from those values; moving the Time scale slider does not.

RK4 does not keep the energy exactly constant, which is why the Drift readout is there. It shows the change \(E - E_0\) from the starting energy divided by \(E_\text{scale} = (m_1+m_2)\,g\,l_1 + m_2\,g\,l_2\), the energy needed to lift both balls from their lowest position to the height of the pivot, rather than by \(E_0\) itself, which can be close to zero. Over the first 20 s of the default start the drift stays within about \(\pm 5\times10^{-8}\); its largest value, \(+5.0\times10^{-8}\), comes at \(t \approx 8.7\ \mathrm{s}\). The page's data store records about \(+4.7\times10^{-8}\) for that picture, but the readout text is rewritten only every sixth picture, so you will usually not catch the peak on screen. After that the drift creeps downward almost in a straight line, by about \(7\times10^{-8}\) a minute: after ten minutes it reads about \(-7\times10^{-7}\).

★ RK4 loses energy rather than gaining it, and the simplest oscillation shows why. Apply it to \(\ddot x = -\Omega^2 x\). One exact step turns the point \((x, \dot x/\Omega)\) round a circle by the angle \(\Omega h\) and keeps its distance from the centre. One RK4 step turns it by almost the same angle but multiplies the distance by \(1 - (\Omega h)^6/144\), slightly less than one. Every step therefore shaves a tiny amount off the swing, as a very weak friction would. Methods built to avoid this, called symplectic integrators, keep the energy from drifting over long times, though they make other small errors.

The step is not equally good everywhere. Put the mass ratio at its top value of 10. Each time the rods pass within about ten degrees of a straight line, the heavy lower ball gives the light upper rod a sharp kick, with angular accelerations up to about \(1300\ \mathrm{rad/s^2}\), against \(75\ \mathrm{rad/s^2}\) for equal masses. Steps of \(h\) are then too coarse to follow the kick, and the drift reaches \(-3.6\times10^{-4}\) within 20 s.

08From metres to pixels

The computer knows the angles; the screen needs dots. The pivot \((x_0, y_0)\) sits at the centre of the picture, which is \(W\) pixels wide and \(H\) high, and the scale is chosen so that the fully stretched pendulum just fits: \(\sigma = (\min(W, H)/2 - 34)/(l_1 + l_2)\) pixels per metre. On a screen, \(y\) is counted downward from the top, the opposite of our convention, so the minus signs of (1) turn into plus signs: ball 1 is drawn at \((x_0 + \sigma l_1\sin\theta_1,\ y_0 + \sigma l_1\cos\theta_1)\), and ball 2 a further \((\sigma l_2\sin\theta_2,\ \sigma l_2\cos\theta_2)\) beyond it. The protractor marks the angle every \(30^\circ\) from the downward vertical, on a faint circle of radius \(\sigma(l_1 + l_2)\), the farthest ball 2 can reach; the dashed circle inside it, of radius \(\sigma l_1\), is the track of ball 1.

The burgundy trail of the lower ball is drawn on its own transparent layer, one short segment per RK4 step, and dimmed every picture by the factor \((1-0.008)^{60\,\Delta t}\), where \(\Delta t\) is the real time since the last picture. In principle its brightness halves every \(\ln 2/(60\,|\ln 0.992|)\approx 1.4\ \mathrm{s}\). The screen, though, stores transparency in whole steps of 1/255, and the tiny dimming steps get rounded away. On a screen drawing sixty pictures a second, the trail falls to half in about 1.6 s and then stops fading at about a quarter of its strength, leaving a faint haze wherever ball 2 has been until Clear trail or a restart; on faster screens it stops fading sooner. Ball 1 is drawn with a radius of 8 screen pixels. Ball 2 has radius \(8(m_2/m_1)^{1/3}\) screen pixels, as for two balls of the same material, whose mass grows with the cube of the radius; it is kept between 4 and 17 pixels.

09Where it flips: films along curves

A child on a swing asks one question before anything else: will I go over the top? For the double pendulum the answer depends on where you let go, and it changes from one degree to the next. Fig. 2b, under the live figure, shows the answer for half a million starts at once, and how it changes when the pendulum itself changes.

Section 6 showed why the live figure cannot be replaced by stored runs. Two starts \(d_0\) apart separate as \(d_0\,e^{\lambda t}\) with \(\lambda \approx 1.4\ \mathrm{s^{-1}}\), so after 20 s the gap has grown by \(e^{28}\approx 10^{12}\): no run between two stored ones can be made from them, and the sliders reach about \(8\times 10^{12}\) different starts. A wave is different. Its equation is linear, solutions add, and one stored ring serves every source; here each start is its own history. So the page keeps its live computation, and what is computed in advance is something the browser could never do in a frame: a map over the starts.

Fix the pendulum and let it go from rest at \((\theta_1, \theta_2)\). Follow it for 10 s with exactly the method of section 7 and note the first moment one rod passes over the top, \(|\theta_1| > \pi\) or \(|\theta_2| > \pi\). Do that for every start on a grid of half a degree, \(720 \times 720 = 518\,400\) pendulums, and colour each point by that time: light for an early flip, dark wine for a late one, blue-black for none within 10 s. That picture is one frame of Fig. 2b.

Part of the picture is decided by energy alone. Released from rest, the pendulum has \(E = V(\theta_1, \theta_2)\), and to put a rod over the top it must reach a configuration with that rod at \(\pi\). The lowest such configurations give two thresholds,

\[ V_1^{*} = (m_1+m_2)\,g\,l_1 - m_2\,g\,l_2, \qquad V_2^{*} = -(m_1+m_2)\,g\,l_1 + m_2\,g\,l_2 , \tag{14} \]

for the upper and the lower rod. A start with \(E < \min(V_1^{*}, V_2^{*})\) can never flip: that is the smooth dark island in the middle of every frame. Outside it energy allows a flip but does not force one, and there the boundary between early, late and never is torn into ever finer filaments, the picture of the chaos of section 6.

The pendulum has more parameters than a picture has axes: the mass ratio, the length ratio and the two starting angular velocities. A film ties them together by one curve through that space, a rule \(p(u)\), \(0 \le u \le 1\), and shows the map at 240 points along it. With two parameters the curve is a path in a plane, drawn beside the film with a dot at the frame shown; with four it is still one path, and it describes one particular relationship between all of them. Five curves are filmed: the lower mass growing from a tenth to ten times the upper (sand pouring in); the lower rod growing from a fifth to five times; a closed loop round the whole mass–length plane; every direction of a starting push of 5 rad/s; and the curve on which the two small-swing tones of section 5 stay exactly an octave apart.

★ The octave curve. Linearise about both rods hanging, as in section 5, with \(x = \Omega^2 l_1/g\), \(\lambda = l_2/l_1\) and \(\mu = m_2/m_1\). The condition \(\det(K - \Omega^2 M) = 0\) becomes \(\lambda x^2 - (1+\mu)(1+\lambda)\,x + (1+\mu) = 0\), whose two roots satisfy \((x_+ + x_-)^2/(x_+ x_-) = (1+\mu)(1+\lambda)^2/\lambda\). A frequency ratio of 2 means \(x_+/x_- = 4\), for which the left side is \(25/4\), so

\[ \frac{m_2}{m_1} = \frac{25}{4}\,\frac{\lambda}{(1+\lambda)^2} - 1 , \qquad 0.295 \le \lambda \le 3.387 . \tag{15} \]

For equal masses and rods the same algebra gives \(x_+/x_- = 3+2\sqrt2\), a ratio \(1+\sqrt2 = 2.414\), the value of section 5, which is a check on the formula.

Each film is computed once on Kaggle's graphics card: \(240 \times 518\,400\) pendulums of 6000 RK4 steps each, about \(7.5\times 10^{11}\) steps, which took about 8000 s per film. Before a film is stored the model checks itself: no start below the thresholds (14) flipped; the map is unchanged when \(\theta \to -\theta\) (with \(\omega \to -\omega\)); 48 random starts give exactly the same step when run again by a plain copy of this page's RK4; and the same map at half the step agrees on every eighth pixel. The film itself is a compressed video, so its colours differ slightly from the stored values; the stored values are read from the maps, never from the picture. Switch on Read a start and click a point: the page shows the stored step, runs the same start again in your browser with its own code, and compares the film's pixel with the colour of the stored value. Swing this start hands that start to the live pendulum above.

10What the model leaves out

Real rods have mass and spread it along their length. A double pendulum made of two solid bars obeys equations of the same kind as ours, with different numbers in front of the terms, because each bar then has its own moment of inertia about its pivot. Real joints and air also take a little energy on every swing. A real double pendulum therefore slows down, its tumbling calms into small regular swings, and these die away; the model, without friction, keeps its energy for ever. In the model the balls may also pass through each other and through the pivot, where real rods would collide.

The last limitation is the computer's, not the model's. After some fifteen to twenty Lyapunov times (\(1/\lambda \approx 0.7\ \mathrm{s}\) each; 10 to 14 s for the default start), the computed path is no longer the exact path from that start: tested against a computation with steps eight times smaller, the page's path is off by a millimetre after 10.9 s and by 10 cm after 14.3 s. It remains a faithful example of how the pendulum can move, just not the one that start would produce. Averages over many swings are usually robust, but they deserve a check too: halve the step, lengthen the run, and see that they stay.

Problems

9.1 Follow the three steps of section 4.2 for the lower angle yourself and arrive at (7). Check every sign that comes from \(\varphi = \theta_1 - \theta_2\).

9.2 Differentiate \(E = T + V\) in time, and use (6) and (7) to show that \(\mathrm{d}E/\mathrm{d}t = 0\).

9.3 Let the upper mass become very heavy, \(m_1 \to \infty\), in (9). Show that the upper rod then swings as a simple pendulum, \(\alpha_1 = -(g/l_1)\sin\theta_1\), and describe in words what the lower pendulum feels.

9.4 Repeat section 5 for equal masses but \(l_2 = 2\,l_1\), and find the two normal-mode frequencies. Then set the length-ratio slider to 2 and compare with the page.

9.2Further reading

  1. J. R. Taylor, Classical Mechanics, University Science Books, 2005: chapters 7 (Lagrange’s equations), 11 (coupled oscillators and normal modes) and 12 (nonlinear mechanics and chaos).
  2. L. D. Landau and E. M. Lifshitz, Mechanics, 3rd edition, Pergamon, 1976: §5, problem 1, the plane double pendulum.
  3. S. H. Strogatz, Nonlinear Dynamics and Chaos, 2nd edition, Westview Press, 2015.
  4. T. Shinbrot, C. Grebogi, J. Wisdom and J. A. Yorke, “Chaos in a double pendulum”, American Journal of Physics 60, 491 (1992): measurements on a real double pendulum, compared with the model of this note.