Transform the double pendulum differential equations into a first order system

I have given a system of differential equations of order two which I want to solve numerically using a Runge-Kutta method. However, I don't know how to transform the system into a system of order one.

Here is the system of equations:

$$\phi{_1}'' +g\sin{\phi_1} + \frac{m_2}{m_1+m_2}\frac{l_2}{l_1}\left(\cos(\phi{_1}-\phi{_2})\phi{_2}''+\sin(\phi{_1}-\phi{_2})(\phi{_2}')^2 \right)=0$$

$$\phi{_2}'' +g\sin{\phi_2} + \frac{l_1}{l_2}\left(\cos{(\phi_1}-\phi_2)\phi{_1}''+\sin(\phi_1-\phi_2)(\phi{_1}')^2 \right)=0$$

Would appreciate help. Thanks

Define $ω_1=ϕ_1'$, $ω_2=ϕ_2'$, $\mu=\frac{m_2}{m_1+m_2}$ and the coordinates of the linear system for the second derivatives \begin{alignat}{6} a_{11}&=1,\;&a_{12}&=\mu\cos(ϕ_1−ϕ_2),\;&b_1&=l_1g\sinϕ_1+l_2\mu\sin(ϕ_1−ϕ_2)ω_2^2\\ a_{21}&=\cos(ϕ_1−ϕ_2),\;&a_{22}&=1,\;&b_2&=l_2g\sinϕ_2+l_1\sin(ϕ_1−ϕ_2)ω_1^2 \end{alignat} and then use Cramers rule to compute the derivative vector \begin{align} ϕ_1'&=ω_1\\ ϕ_2'&=ω_2\\ ω_1'&=-\frac{1}{l_1}·\frac{b_1·a_{22}-b_2·a_{12}}{a_{11}·a_{22}-a_{21}a_{12}}\\ ω_2'&=-\frac{1}{l_2}·\frac{a_{11}·b_2-a_{21}·b_1}{a_{11}·a_{22}-a_{21}a_{12}}\\ \end{align}
• I made a mistake int the second equation should be like this: $\frac{l_1}{l_2}$ instead of $\mu$ in $b_2$. Additionally, I think you forgot $a_{21}$ (You have $a_{12}$ twice) – XPenguen Jan 5 '17 at 17:39
• Done. I also changed the linear system to be for $(l_1ω_1')$ and $(l_2ω_2')$ and moved the length division and sign change to the final formula. – LutzL Jan 5 '17 at 18:28