Skip to content


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time


alt text alt text alt text alt text

alt text Animation of the chaotic motion a double-pendulum using Julia and Python. The julia version is implemented in a Jupyter notebook environment whereas the python version is a conventional script. Double pendulums of arbitrary lengths, masses, initial positions, and the initial velocities can be simulated using this code. Both versions of the code allow the animation to be saved in either mp4 or gif format.

Julia version alt text

The code can save the animation as a gif file. It can also playback the video in Jupyter notebook environment. The animation is recorded at equal time steps to preserve relative velocity of the pendulums in the video.

Python version alt text

The animation is done using FuncAnimation() of matplotlib. The code can save the animation as a mp4 file. The python script was tested in spyder environment. Plotting in external window should be enabled to view the animation.

Package requirements for Julia version

  1. Plots
  2. Differential Equations
  3. Direckx

Package requirements for Python version

  1. numpy
  2. scipy.integrate (odeint)
  3. pylab, matplotlib (animation)
  4. imagemagick (to save animation as a gif file)


The mass and length of the pendulums, gravitational acceleration constant, the initial conditions and the simulaiton duration are defined at the beginning of the code. Different cases can be simulated by changing these parameters.

Sample output

Double pendulum system animation. The left animation is from the julia code with m1 = m2 = 1kg, L1 = L2 = 1m, initial conditions: θ1 = 5π/8, θ2 = 5π/9, ω1 = 0, ω2 = 0. The right animation is from the python code with m1 = 2kg, m2 = 1kg, L1 =1.4m, L2 = 1m, initial conditions: θ1 = 5π/11, θ2 = 5π/9, ω1 = 0, ω2 = 0.

Here, θ1 and θ2 are the initial angular positions, and, ω1 and ω2 are initial angular velocities in SI units.

alt text alt text