Introduction
I'd like to preface this by saying that while I'm a reasonably competent developer, my calculus skills leave a lot to be desired.
I've been reading up on basic physics, and I thought I had a grip on the behaviour of the Lagrangian formulation of physics, but it turns out there is something I just don't understand, which is why I'm turning to this place for assistance.
I've been simulating various systems like pendulums, gravitational systems, etc and my very simplistic approach has worked fine. However, when I tried it on the double pendulum, I'm not getting the expected results.
Calculating the Lagrangian
I'm assuming the coordinates of the masses:
$$ \begin{align} x_1 &= sin(θ_1)\,l_1 \\ x_2 &= x_1 + sin(θ_2)\,l_2 \\ y_1 &= -cos(θ_1)\,l_1 \\ y_2 &= y_1 - cos(θ_2)\,l_2 \end{align} $$
I then use Maxima to compute the Lagrangian, which is:
$$ {{2\,l_{1}\,l_{2}\,m_{2}\,\dot{θ}_{1}\,\dot{θ}_{2}\,\sin θ_{1}\,\sin θ_{2}+ \left(2\,l_{1}\,l_{2}\,m_{2}\,\dot{θ}_{1}\,\dot{θ}_{2}\,\cos θ_{1}+2\,g\,l_{2}\, m_{2}\right)\,\cos θ_{2}+\left(2\,g\,l_{1}\,m_{2}+2\,g\,l_{1}\,m_{1} \right)\,\cos θ_{1}+l_{2}^2\,m_{2}\,\dot{θ}_{2}^2+\left(l_{1}^2\,m_{2}+ l_{1}^2\,m_{1}\right)\,\dot{θ}_{1}^2}\over{2}} $$
I then use the Euler-Lagrange equation to give me the solution for the first coordinate:
$$ \ddot{θ}_1 = -{{\left(\ddot{θ}_{2}\,l_{2}\,m_{2}\,\sin θ_{1}-l_{2}\,m_{2}\,\dot{θ}_{2}^2\, \cos θ_{1}\right)\,\sin θ_{2}+\left(l_{2}\,m_{2}\,\dot{θ}_{2}^2\,\sin θ_{1}+\ddot{θ}_{2}\,l_{2}\,m_{2}\,\cos θ_{1}\right)\,\cos θ_{2}+\left(g\, m_{2}+g\,m_{1}\right)\,\sin θ_{1}}\over{l_{1}\,m_{2}+l_{1}\,m_{1}}} $$
And the solution for the second coordinate:
$$ \ddot{θ}_2 = -{{\left(\ddot{θ}_{1}\,l_{1}\,\sin θ_{1}+l_{1}\,\dot{θ}_{1}^2\,\cos θ_{1}+g \right)\,\sin θ_{2}+\left(\ddot{θ}_{1}\,l_{1}\,\cos θ_{1}-l_{1}\,\dot{θ}_{1}^2\, \sin θ_{1}\right)\,\cos θ_{2}}\over{l_{2}}} $$
While my Lagrangian looks a bit different from the typical one I can find when searching online for the Lagrangian for a double pendulum, they do seem to be equivalent, and I did try to enter the one I found online and I get the same numbers from that one.
Trying to simulate the motion
Once I got this, I wanted to simulate it in the same simplistic manner as I have have simulated other physical systems, by accumulating the positions and velocities.
For each iteration, I compute 6 variables like so:
$$ \texttt{thetadotdot_1 = } \ddot{\theta}_1 \Delta t \texttt{ /* The result above */} \\ \texttt{thetadotdot_2 = } \ddot{\theta}_2 \Delta t \texttt{ /* The result above */} \\ \texttt{thetadot_1 = thetadot_1 + thetadotdot_1} \\ \texttt{thetadot_2 = thetadot_2 + thetadotdot_2} \\ \texttt{theta_1 = theta_1 + thetadot_1} \\ \texttt{theta_2 = theta_2 + thetadot_1} $$
I then draw the two objects based on theta_1 and theta_2 alogn with the values of $l_1$ and $l_2$.
The problem I am facing is that while the two objects swings back and forth, they do so completely independently. Each one swings like a regular pendulum, without being influenced by the other. The fact that they swing at all suggests that the way I approach the problem isn't entirely wrong, but I clearly made a mistake somewhere.
I'd be very happy is someone could point out where my mistake is?