Chaos in The Double Pendulum

Download as pdf or txt
Download as pdf or txt
You are on page 1of 9

Chaos in the Double Pendulum

Chaotic Trajectories of ODE Systems


What is the smallest number of coupled ordinary differential equations that exhibits chaotic behavior?
This depends on whether or not the equations depend explicitly on time. If the equations depend on time,
then the minimum number is two. If they do not, at least three equations are required for chaotic behavior
to occur.
Chaos in the kicked rotor, which equivalent to the standard map, is a result of a periodic kicking force that
depends on the angular position of the rotor.
Chaos in the nonlinear driven damped pendulum results from the competition between nonlinearity,
driving, and damping, with the magnitude of the damping force being the critical parameter.
The phase spaces of the rotor and pendulum are 2-dimensional. In both systems, the equations depend
explicitly on time through the kicking or driving force terms.
The Lorenz model is a system of three coupled first order ordinary differential equations which has chaotic
trajectories.
The phase space of a Hamiltonian system has an even number of dimensions because each generalized
coordinate is paired with its canonically conjugate generalized momentum. If the Hamiltonian does not
depend on time, then the energy of the system is constant and provides a first integral of motion. Any
time-independent Hamiltonian system with a 2-dimensional phase space is integrable. A time-independent
Hamiltonian system must have at least a 4-dimensional phase space for chaotic trajectories to occur.

The Double Pendulum


The double pendulum consists of two simple pendulums that are attached to one another as shown in
Fig. 1. The top and center pivots are assumed frictionless, and the coupled objects are free to rotate about
them in the vertical plane under the action of gravity.

y x
l1
1 m1
l
2 2 m2

Figure 1: A double pendulum consisting of two simple pendulums.

The double pendulum is the simplest example of a time-independent Hamiltonian system that exhibits
chaotic behavior. Its phase space is 4-dimensional.
Chaos can be demonstrated experimentally in the double pendulum[1],[2].

1
Euler-Lagrange Equations
Suppose that the upper pendulum has a massless rod of length `1 and a bob of mass m1 . The lower
pedulum has a massless rod of length `2 and bob of mass m2 . The two rods provide constraints on the
motion of the two masses in the vertical plane:

x1 = `1 sin 1 , y1 = `1 cos 1 , (1)

x2 = `1 sin 1 + `2 sin 2 , y2 = `1 cos 1 `2 cos 2 . (2)


There are therefore only two independent generalized coordinates, which can be taken to be the angles 1
and 2 that the two rods make with the downward vertical direction.
The Lagrangian for the double pendulum is
m1 2  m2 2
x1 + y12 + x2 + y22 m1 gy1 m2 gy2

L = (3)
2 2
1 1
= (m1 + m2 )`1 1 + m2 `22 22 + m2 `1 `2 2 2 cos(1 2 )
2 2
(4)
2 2
+(m1 + m2 )g`1 cos 1 + m2 g`2 cos 2 . (5)

The Euler-Lagrange equations for 1 and 2 are


 
d L L
= . (6)
dt i i

The 1 equation is
h i
`1 (m1 + m2 )`1 1 + m2 `2 cos(1 2 )2 + m2 `2 sin(1 2 )22 + (m1 + m2 )g sin 1 = 0 , (7)

and the 2 equation is


h i
m2 `2 `2 2 + `1 cos(1 2 )1 `1 sin(1 2 )12 + g sin 2 = 0 . (8)

Small Oscillations

When the amplitudes of oscillation are small, the equations of motion can be linearized to find the normal
modes:
(m1 + m2 )`1 1 + m2 `2 2 + (m1 + m2 )g1 = 0 , (9)
`2 2 + `1 1 + g2 = 0 . (10)
Normal mode solutions have the form:
   
1 (t)
= 10 eit . (11)
2 (t) 20

The normal mode frequencies are determined by solving the secular equation

m1 (g 2 `1 ) m2 `2 2
=0. (12)
`1 2 (g 2 `2 )

2
The solutions of the secular equation are:
s 
 2 
`1 `2
  m1 + m2 (m1 + m2 ) m2 + m1 `1 +`2
2 g(`1 + `2 )
= . (13)
2`1 `2
m1

The normal mode amplitudes are related by


20 g 2 `2
= . (14)
10 2 `1

Consider the special case of equal masses and lengths, m1 = m2 = m and `1 = `2 = L:


g
r
= (2 2) , (15)
L

20 1 2
= . (16)
10 2 2
The higher frequency mode has the masses moving out of phase, and the lower frequency mode has the
masses moving in phase.
In the limit `2 0, one of the frequencies becomes infinite, corresponding to a simple pendulum of zero
length. The other frequency can be evaluated using lHopitals rule
g
2 = , (17)
`1
which is the frequency of a simple pendulum of length `1 , and
20
=1, (18)
10
corresponding to the two masses oscillating synchronously.

Hamiltons Equations
To derive the Hamiltonian equations for the double pendulum, start from the Lagrangian
1 1
L=T V = m1 v12 + m2 v22 m1 gy1 m2 gy2 , (19)
2 2
where T is the kinetic energy, and V is the potential energy, and g is the acceleration of gravity.
The generalized momenta can be found from the Lagrangian:
L
p1 = = (m1 + m2 )`21 1 + m2 `1 `2 2 cos(1 2 ) , (20)
1
L
p 2 = = m2 `22 2 + m2 `1 `2 1 cos(1 2 ) . (21)
2

The Hamiltonian is the Legendre transform of the Lagrangian:

H(1 , 2 , p1 , p2 ) = 1 p1 + 2 p2 L . (22)

3
The velocities can be expressed as functions of the coordinates and momenta:
`2 p1 `1 p2 cos(1 2 )
1 = , (23)
`1 `2 m1 + m2 sin2 (1 2 )
2
 

`1 (m1 + m2 )p2 `2 m2 p1 cos(1 2 )


2 = . (24)
`1 `22 m2 m1 + m2 sin2 (1 2 )
 

The Hamiltonian is
m2 `22 p21 + (m1 + m2 )`21 p22 2m2 `1 `2 p1 p2 cos(1 2 )
H =
2`21 `22 m2 m1 + m2 sin2 (1 2 )
 

(m1 + m2 )g`1 cos 1 m2 g`2 cos 2 . (25)

Hamiltons equations for the time rate of change of the generalized momenta are
H K
p1 = = (m1 + m2 )g`1 sin(1 ) , (26)
1 1
H K
p2 = = m2 g`2 sin(2 ) , (27)
2 2
where the generalized kinetic energy
m2 `22 p21 + (m1 + m2 )`21 p22 2m2 `1 `2 p1 p2 cos(1 2 )
K H V = . (28)
2`21 `22 m2 m1 + m2 sin2 (1 2 )
 

Note that K depends on the generalized coordinates only through the difference 1 2 . Hence
K K m2 `22 p21 + (m1 + m2 )`21 p22 2m2 `1 `2 p1 p2 cos(1 2 )
= = 2 sin[2(1 2 )]
2 1 2`21 `22 m1 + m2 sin2 (1 2 )


p p sin(1 2 )
 1 2
`1 `2 m1 + m2 sin2 (1 2 )


m K sin[2(1 2 )] p p sin(1 2 )
=  2 2
  1 2 . (29)
m1 + m2 sin (1 2 ) `1 `2 m1 + m2 sin2 (1 2 )

Simulating the Double Pendulum


With Hamiltons equations in vector form, it is straightforward to apply the Runge-Kutta algorithm to
solve for the trajectories of the double pendulum.
For the simulation, assume that the two masses are equal m1 = m2 = m and that the two two lengths are
also equal `1 = `2 = L. Hamiltons equations reduce to
p1 p2 cos(1 2 )

1 2 2
mL [1+sin (1 2 )]
d 2p2 p1 cos(1 2 )
2 =

, (30)

mL2 [1+sin2 (1 2 )]
dt p1 2mgL sin 1 C1 + C2

p2 mgL sin 2 + C1 C2
where
p1 p2 sin(1 2 )
C1 = , (31)
mL2 [1 + sin2 (1 2 )]
p21 + 2p22 2p1 p2 cos(1 2 )
C2 = sin[2(1 2 )] . (32)
2mL2 [1 + sin2 (1 2 )]2

4
Poincare Section

Because the phase space of the system is 4-dimensional and hard to visualize, it is useful to look at a
Poincare section, for example, the intersections of the trajectory with a 2-dimensional slice of the phase
space.
Because the Hamiltonian H is conserved in time, the trajectories actually lie on a 3-dimensional
hypersurface determined by the equation

1 p21 + 2p22 2p1 p2 cos(1 2 )


E = H + 3mgL = + mgL(3 2 cos 1 cos 2 ) , (33)
2mL2 1 + sin2 (1 2 )
in the case of equal masses and lengths. A constant has been added to H so E = 0 at the stable
equilibrium position.
A simple choice of section is obtained by focusing on the phase space of the upper mass, and recording its
position and momentum 1 , p1 every time the trajectory crosses the hypersurface defined by 2 = 0 when
the second mass hangs momentarily vertically below the first. At this instant of time the lower mass can be
moving in the clockwise or the counterclockwise directions: the Poincare section can be simplified by
plotting intersections only when the lower mass is moving clockwise, i.e., when p2 > 0.

C++ Program

The following program generates the pendulum trajectory and Poincare section data.
Program 1: http://www.physics.buffalo.edu/phy410-505/topic4/dpendulum.cpp

#include <cmath>
#include <cstdlib>
#include <fstream>
#include <iostream>
#include <vector>
using namespace std;

#include "linalg.hpp"
#include "odeint.hpp"
using namespace cpl;

const double pi = 4 * atan(1.0); // value of pi


const double g = 9.8; // acceleration of gravity
double L = 1; // length of each pendulum
double m = 1; // mass of each pendulum bob

bool switch_t_and_theta_2 = false;// to zero in on section point

vector<double> f( // extended flow vector for Runge-Kutta


const vector<double>& x // extended solution vector
) {

double t = x[0], theta_1 = x[1], theta_2 = x[2], p_1 = x[3], p_2 = x[4];

double sin12 = sin(theta_1 - theta_2),

5
cos12 = cos(theta_1 - theta_2),
sin212 = sin(2 * (theta_1 - theta_2)),
denom = 1 + sin12 * sin12;

double C_1 = p_1 * p_2 * sin12 / (m * L * L * denom),


C_2 = (p_1 * p_1 + 2 * p_2 * p_2 - 2 * p_1 * p_2 * cos12)
* sin212 / (2 * m * L * L * denom * denom);

vector<double> f(5);
f[0] = 1;
f[1] = (p_1 - p_2 * cos12) / (m * L * L * denom);
f[2] = (2 * p_2 - p_1 * cos12) / (m * L * L * denom);
f[3] = - 2 * m * g * sin(theta_1) - C_1 + C_2;
f[4] = - m * g * L * sin(theta_2) + C_1 - C_2;

if (switch_t_and_theta_2) {
double d_theta_2_dt = f[2];
f /= d_theta_2_dt; // change variable from t to theta_2
}

return f;
}

double Energy( // conserved energy


const vector<double>& x // extended solution vector
) {

double t = x[0], theta_1 = x[1], theta_2 = x[2], p_1 = x[3], p_2 = x[4];
double sin12 = sin(theta_1 - theta_2),
cos12 = cos(theta_1 - theta_2);

return 1 / (2 * m * L * L * (1 + sin12 * sin12))


* (p_1 * p_1 + 2 * p_2 *p_2 - 2 * p_1 * p_2 * cos(theta_1 - theta_2))
+ m * g * L * (3 - 2 * cos(theta_1) - cos(theta_2));
}

double p_theta_2( // solve for p_theta_2


const double E, // given energy E
const double theta_1, // position of upper pendulum
const double theta_2, // position of lower pendulum
const double p_1 // momentum of upper pendulum
) {

double sin12 = sin(theta_1 - theta_2),


cos12 = cos(theta_1 - theta_2),
denom = 2 * m * L * L * (1 + sin12 * sin12);

double a = 2 / denom,
b = - 2 * p_1 * cos12 / denom,
c = p_1 * p_1 / denom - E
+ m * g * L * (3 - 2 * cos(theta_1) - cos(theta_2));

6
double discr = b * b - 4 * a * c;
if (discr < 0) {
cerr << " Sorry, E = " << E << " too small, cannot solve for p_theta_2"
<< endl;
exit(EXIT_FAILURE);
}

return (- b + sqrt(discr)) / (2 * a);


}

int main() {

cout << " Chaos in the Double Pendulum\n"


<< " ----------------------------\n"
<< " Enter E, theta_1, theta_2, p_theta_1: ";
double E, theta_1, theta_2, p_1;
cin >> E >> theta_1 >> theta_2 >> p_1;
double p_2 = p_theta_2(E, theta_1, theta_2, p_1);
cout << " Enter number of section points: ";
int section_points;
cin >> section_points;
ofstream trajectory_file("trajectory.data");
ofstream section_file("section.data");

double t = 0;
vector<double> x(5); // extended solution vector
x[0] = t; x[1] = theta_1; x[2] = theta_2; x[3] = p_1; x[4] = p_2;

RK4 rk4;
double dt = 0.001;
double accuracy = 1e-6;
rk4.set_step_size(dt);
rk4.set_accuracy(accuracy);

int crossing = 0;
while (true) {

trajectory_file << x[0] << \t << x[1] << \t << x[2]


<< \t << x[3] << \t << x[4] << \n;
double theta_2_old = x[2];

rk4.adaptive_step(f, x);

if (theta_2_old < 0.0 && x[2] >= 0.0 && x[4] >= 0.0) {

++crossing;
switch_t_and_theta_2 = true;
double dt_save = rk4.get_step_size();

vector<double> x_map = x;

7
double d_theta_2 = -x_map[2];
rk4.set_step_size(d_theta_2);
rk4.step(f, x_map);

switch_t_and_theta_2 = false;
rk4.set_step_size(dt_save);
cout << "Crossing " << crossing << " theta_1 = " << x_map[1]
<< " p_theta_1 = " << x_map[3] << " Energy = "
<< Energy(x_map) << endl;
section_file << x_map[1] << \t << x_map[3] << \n;
}

if (crossing >= section_points)


break;
}

trajectory_file.close();
section_file.close();
}

Fig. 2 shows two trajectories of the double pendulum with the same energy: one set of initial conditions
results in a multiply periodic trajectory; a different set initial conditions lead to chaos!

Double Pendulum E = 15 Section at 2 = 0 p > 0


2
8
1(0) = 0.0
1(0) = 1.1

2
1
p

-2

-4

-6
-1.5 -1 -0.5 0 0.5 1 1.5
1

Figure 2: Poincare sections with 5000 points for the double pendulum with E = 15. The chaotic trajectory
(red dots) results from choosing initial conditions 1 = 0, 2 = 0, p1 = 0, and the periodic trajectory (green
dots) from 1 = 1.1, 2 = 0, p1 = 0.

8
Homework Problem
First consider small oscillations. Simulate the two normal modes of the double pendulum: measure the
normal mode frequencies and verify the mode behavior by plotting the trajectories 1,2 (t).
Next, explore the full nonlinear behavior by generating Poincare sections for energy E = 1, 5, 10, 15, 40. Try
different initial conditions for each value of the energy E. For example, with E = 15, try the two different
initial values sets (1) 1 = 1.1, and 2 = 0, and (2) 1 = 0, and 2 = 0. Describe qualitatively the types of
motion you observe.

References
[1] T. Shinbrot, C. Grebogi and J. Wisdom, Chaos in a double pendulum, Am. J. Phys. 60, 491 (1992),
http://dx.doi.org/10.1119/1.16860.
[2] R.B. Levien and S.M. Tan, Double pendulum: An experiment in chaos, Am. J. Phys. 61, 1038
(1993), http://dx.doi.org/10.1119/1.17335.
[3] Double pendulum Java applet from a previous course:
http://www.physics.buffalo.edu/gonsalves/phy410-505_fall00/Chapter6/oct27.html.

You might also like