The masses and the lengths are the same. The only free parameter in the simulation is the frequency:
Let's call the angles
And the total energy (scaled by
The simulation is made using 4th order Runge-Kutta scheme, and the animation is created using the macroquad crate.
Added dissipative force, which user can control. The force changes the momentum equations:
This should be the right way to account for air friction, and the simulation looks good.
Also added a lot of interactivity. You can now reset the simulation without rebooting the program. You can also give the pendulum a "boost" with arrow keys during simulation. Try it with friction on!