Member-only story

Modeling a Double Pendulum with Python and Sympy

Rhett Allain
11 min readNov 28, 2022

--

Photo: Rhett Allain. Double Pendulum.

I’ll be honest. This is really just a big reminder for me. You see, I’m going to forget how to do this at some point in the future. So hopefully, when I do an internet search on the double pendulum I will find this post. Really, that makes this sort of like a time machine since I am communicating with the future. Hello, Future Rhett.

Simple Pendulum

Now for the physics. I want to model a double pendulum, but we need to start with something simpler — like a normal pendulum. For this, I’m going to use Lagrangian mechanics. Oh, you don’t know much about that? Don’t worry, I have you covered.

I need to get a solution, I need the Lagrangian for this system. It’s the difference in the kinetic (T) and potential energy (U).

For this simple pendulum, there is only one degree of freedom. That means I can express everything in terms of single variable with the obvious choice of θ. But it’s not completely trivial to get the kinetic energy in terms of θ. So, instead I will write it in terms of Cartesian coordinates.

--

--

Rhett Allain
Rhett Allain

Written by Rhett Allain

Physics faculty, science blogger of all things geek. Technical Consultant for CBS MacGyver and MythBusters. WIRED blogger.

No responses yet