Abstract. We present a concise, reproducible Wolfram Language workflow for modeling and visualizing the planar dynamics of an undamped double pendulum. Motivated by the need for a clear, teachable example of nonlinear multi-body motion, we derive the equations via the Lagrangian approach from the generalized coordinates and , then solve them numerically over a chosen time window. Time series, a - phase portrait, and path traces are generated by the notebook, and strong energy exchange and tangled, non-closing trajectories indicative of chaos are revealed. The workflow is intended for students and instructors seeking an extensible template to begin studying chaotic dynamics.
θ
1
θ
2
θ
2
θ
1
(x,y)
1. System Setup and Kinematics
1. System Setup and Kinematics
A double pendulum is formed by suspending one pendulum from the end of another. Although the setup is mechanically simple, it provides a striking example of a system that can exhibit chaotic motion. Consider a double pendulum consisting of two equal point masses ==0.25 kg, connected by rigid, massless wires of lengths =0.22 m and =0.18 m. The angles that the two wires make with the vertical are denoted by and , as shown in Fig. 1. The gravitational acceleration is taken to be .
m
1
m
2
l
1
l
2
θ
1
θ
2
g=9.81m/
2
s
Define the system parameters by specifying the masses, pendulum lengths, and gravitational acceleration:
In[]:=
m1=m2=0.25;l1=0.22;l2=0.18;g=9.81;
Determine the location of the fixed pivot point and the instantaneous positions of the pendulum masses:
In[]:=
o={0,0,0};p1={1,-2,0};p2={2.5,-3,0};
Create labeled elements and pendulum geometry:
In[]:=
labeledGrphics=Style[Inset[#1,#2],16,Italic,FontFamily->"Times",Bold]&@@@,;
In[]:=
PaneGraphics3DlabeledGrphics,,ImageSize->Scaled[1]
Out[]=
The instantaneous coordinates of the two masses, and , can be expressed in terms of the lengths and , together with the time-dependent angles (t) and (t), as follows:
((t),(t))
x
1
y
1
((t),(t))
x
2
y
2
l
1
l
2
θ
1
θ
2
x 1 l 1 θ 1 |
y 1 l 1 θ 1 |
x 2 l 1 θ 1 l 2 θ 2 |
y 2 l 1 θ 1 l 2 θ 2 |
Express the instantaneous coordinates of the masses in terms of the lengths and time-dependent angles:
In[]:=
x1[t_]:=l1Sin[θ1[t]]y1[t_]:=-l1Cos[θ1[t]]x2[t_]:=l1Sin[θ1[t]]+l2Sin[θ2[t]]y2[t_]:=-l1Cos[θ1[t]]-l2Cos[θ2[t]]
The kinetic energy accounts for the motion of both pendulum masses through their speeds (t) and (t), while the potential energy represents their gravitational energy based on vertical distances (t) and (t):
(t)
v
1
v
2
(t)
y
1
y
2
(t)= 1 2 m 1 2 v 1 1 2 m 2 2 v 2 |
(t)= m 1 y 1 m 2 y 2 |
The speeds can be defined in terms of the time derivatives of the coordinates, with the dot notation indicating differentiation with respect to time:
v 1 2 x 1 2 y 1 |
v 2 2 x 2 2 y 2 |
Formulate the kinetic and potential energy of the system (derivatives appear as dashes in the code):
In[]:=
[t_]:=m1(+)+m2(+);[t]//Simplify
1
2
2
x1'[t]
2
y1'[t]
1
2
2
x2'[t]
2
y2'[t]
Out[]=
0.0121[t]+0.0099Cos[θ1[t]-θ2[t]][t][t]+0.00405[t]
2
′
θ1
′
θ1
′
θ2
2
′
θ2
In[]:=
[t_]:=m1gy1[t]+m2gy2[t];[t]//Simplify
Out[]=
-1.0791Cos[θ1[t]]-0.44145Cos[θ2[t]]
2. Lagrangian and Equations of Motion
2. Lagrangian and Equations of Motion
In relatively complex dynamical systems, the Lagrangian formalism is often preferred because it works with scalars (kinetic and potential energies) rather than vectors (forces and accelerations as in Newton’s laws). This avoids splitting forces into components, which makes the analysis much simpler for systems like the double pendulum. The Lagrangian of a mechanical system is defined as the difference between its kinetic and potential energies: . A discussion of the double pendulum using Newtonian mechanics can be found in the double pendulum topic of the Wolfram documentation.
ℒ(t)=(t)–(t)
Define the Lagrangian of the system:
In[]:=
ℒ[t_]:=[t]-[t];ℒ[t]//Simplify
Out[]=
1.0791Cos[θ1[t]]+0.44145Cos[θ2[t]]+0.0121[t]+0.0099Cos[θ1[t]-θ2[t]][t][t]+0.00405[t]
2
′
θ1
′
θ1
′
θ2
2
′
θ2
To derive the equations of motion for the double pendulum, we apply the Euler–Lagrange equation to the generalized coordinates and . For each angle, the equation takes the form:
θ
1
θ
2
d dt ∂ℒ ∂ θ 1 ∂ℒ ∂ θ 1 |
d dt ∂ℒ ∂ θ 2 ∂ℒ ∂ θ 2 |
Derive the equations of motion using the Euler–Lagrange equations:
In[]:=
diffEqns=Simplify[D[D[ℒ[t],D[#,t]],t]-D[ℒ[t],#]]==0&/@{θ1[t],θ2[t]}
Out[]=
{1.0791Sin[θ1[t]]+0.0099Sin[θ1[t]-θ2[t]][t]+0.0242[t]+0.0099Cos[θ1[t]-θ2[t]][t]0,0.44145Sin[θ2[t]]-0.0099Sin[θ1[t]-θ2[t]][t]+0.0099Cos[θ1[t]-θ2[t]][t]+0.0081[t]0}
2
′
θ2
′′
θ1
′′
θ2
2
′
θ1
′′
θ1
′′
θ2
In[]:=
Needs["VariationalMethods`"]EulerEquations[ℒ[t],{θ1[t],θ2[t]},t]
Out[]=
{-1.0791Sin[θ1[t]]-0.0099Sin[θ1[t]-θ2[t]][t]-0.0242[t]-0.0099Cos[θ1[t]-θ2[t]][t]0,-0.44145Sin[θ2[t]]+0.0099Sin[θ1[t]-θ2[t]][t]-0.0099Cos[θ1[t]-θ2[t]][t]-0.0081[t]0}
2
′
θ2
′′
θ1
′′
θ2
2
′
θ1
′′
θ1
′′
θ2
ResourceFunction["EulerEquations"][ℒ[t],{θ1[t],θ2[t]},t]
Out[]=
{-1.0791Sin[θ1[t]]-0.0099Sin[θ1[t]-θ2[t]][t]-0.0242[t]-0.0099Cos[θ1[t]-θ2[t]][t]0,-0.44145Sin[θ2[t]]+0.0099Sin[θ1[t]-θ2[t]][t]-0.0099Cos[θ1[t]-θ2[t]][t]-0.0081[t]0}
2
′
θ2
′′
θ1
′′
θ2
2
′
θ1
′′
θ1
′′
θ2
We then set the initial conditions ((0)=π/2,(0)=0,(0)=π/2, and (0)=0), combine the equations of motion with these conditions into a single initial-value problem, and solve it numerically.
θ
1
θ
1
θ
2
θ
2
Set the initial conditions for both pendulum angles and their velocities:
In[]:=
initCond={θ1[0]==π/2,θ1'[0]==0,θ2[0]==π/2,θ2'[0]==0};
Combine the differential equations with the initial conditions into a single system:
In[]:=
eqnsSet=Join[diffEqns,initCond];eqnsSet//Column
Out[]=
1.0791Sin[θ1[t]]+0.0099Sin[θ1[t]-θ2[t]] 2 ′ θ2 ′′ θ1 ′′ θ2 |
0.44145Sin[θ2[t]]-0.0099Sin[θ1[t]-θ2[t]] 2 ′ θ1 ′′ θ1 ′′ θ2 |
θ1[0] π 2 |
′ θ1 |
θ2[0] π 2 |
′ θ2 |
Solve the system numerically over the chosen time interval:
In[]:=
sol=First[NDSolve[eqnsSet,{θ1,θ2},{t,0,15}]]
θ1InterpolatingFunction,θ2InterpolatingFunction
3. Results and Visual Analysis
3. Results and Visual Analysis
Fig. 2 shows two complementary views over 0–15 s. Fig. 2a plots the time series of (t) and (t), and Fig. 2b shows the angle–angle trajectory (t) versus (t). In Fig. 2a, (t) displays larger excursions and intermittent bursts of rapid growth, consistent with strong energy exchange and sensitivity to initial conditions. In contrast, (t) remains more bounded with smaller-amplitude oscillations. In Fig. 2(b), the trajectory traces a tangled, non-closing path, indicating aperiodic motion and chaos.
θ
1
θ
2
θ
2
θ
1
θ
2
θ
1
Plot the time series of θ₁(t), θ₂(t) and the angle–angle trajectory (θ₂ vs. θ₁):
RowPlotEvaluate[#],{t,0,15},,ParametricPlot#,{t,0,15},," "&[{θ1[t],θ2[t]}/.sol]
Out[]=
Fig. 3 plots the trajectories of the two pendulum masses over 0–15 s. Imagine each mass carrying a pen that draws its path as it moves— in blue and in red. The inner, shorter track belongs to , which stays closer to the pivot, while sweeps a wider region, marked by loops and cusps that indicate rapid direction changes. The dense self-intersections and absence of a closed loop indicate aperiodic motion and ongoing energy exchange between the arms.
x–y
m
1
m
2
m
1
m
2
Plot the trajectories of the two pendulum masses:
x–y
ParametricPlot{{x1[t],y1[t]}/.sol,{x2[t],y2[t]}/.sol},{t,0,15},
Out[]=
Define a linear opacity ramp fade[i,t] so older trail segments fade to transparent over the last tail seconds:
Generate frames for the double pendulum and the masses’ x–y trajectories:
Play the sequence of frames with interactive controls:
References
References
CITE THIS NOTEBOOK
CITE THIS NOTEBOOK
Modeling a double pendulum with Lagrangian mechanics
by Akram Masoud
Wolfram Community, STAFF PICKS, September 17, 2025
https://community.wolfram.com/groups/-/m/t/3546957
by Akram Masoud
Wolfram Community, STAFF PICKS, September 17, 2025
https://community.wolfram.com/groups/-/m/t/3546957