```python
from sympy.physics.mechanics import *
import sympy as sp
mechanics_printing(pretty_print=True)
```


```python
m1, m2, m3, m4, l1, l2, l3, l4 = sp.symbols(r'm_1 m_2 m_3 m_4 l_1 l_2 l_3 l_4')
t, g, h = sp.symbols('t g h')
v1, v2, v3, v4 = dynamicsymbols(r'\theta_1 \theta_2 \theta_3 \theta_4')
dv1, dv2, dv3, dv4 = dynamicsymbols(r'\theta_1 \theta_2 \theta_3 \theta_4', 1)
ddv1, ddv2, ddv3, ddv4 = dynamicsymbols(r'\theta_1 \theta_2 \theta_3 \theta_4', 2)
```


```python
x1 = l1 * sp.sin(v1)
y1 = -l1 * sp.cos(v1)
x2 = x1 + l2 * sp.sin(v2)
y2 = y1 + -l2 * sp.cos(v2)
x3 = x2 + l3 * sp.sin(v3)
y3 = y2 + -l3 * sp.cos(v3)
x4 = x3 + l4 * sp.sin(v4)
y4 = y3 + -l4 * sp.cos(v4)

dx1 = x1.diff(t)
dy1 = y1.diff(t)
dx2 = x2.diff(t)
dy2 = y2.diff(t)
dx3 = x3.diff(t)
dy3 = y3.diff(t)
dx4 = x4.diff(t)
dy4 = y4.diff(t)
```


```python
V = (m1 * g * y1) + (m2 * g * y2) + (m3 * g * y3) + (m4 * g * y4)
T = (sp.Rational(1, 2) * m1 * (dx1**2 + dy1**2)) + (sp.Rational(1, 2) * m2 * (dx2**2+dy2**2)) + (sp.Rational(1, 2) * m3 * (dx3**2 + dy3**2)) + (sp.Rational(1, 2) * m4 * (dx4**2 + dy4**2))
L = T - V
```


```python
LM = LagrangesMethod(L, [v1, v2, v3, v4])
```


```python
soln = LM.form_lagranges_equations()
```


```python
sp.latex(soln)
```




    '\\left[\\begin{matrix}g l_{1} m_{1} \\sin{\\left(\\theta_{1}{\\left(t \\right)} \\right)} + g l_{1} m_{2} \\sin{\\left(\\theta_{1}{\\left(t \\right)} \\right)} + g l_{1} m_{3} \\sin{\\left(\\theta_{1}{\\left(t \\right)} \\right)} + g l_{1} m_{4} \\sin{\\left(\\theta_{1}{\\left(t \\right)} \\right)} + \\frac{m_{1} \\left(2 l_{1}^{2} \\sin^{2}{\\left(\\theta_{1}{\\left(t \\right)} \\right)} \\frac{d^{2}}{d t^{2}} \\theta_{1}{\\left(t \\right)} + 2 l_{1}^{2} \\cos^{2}{\\left(\\theta_{1}{\\left(t \\right)} \\right)} \\frac{d^{2}}{d t^{2}} \\theta_{1}{\\left(t \\right)}\\right)}{2} - \\frac{m_{2} \\left(2 l_{1} \\left(l_{1} \\sin{\\left(\\theta_{1}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{1}{\\left(t \\right)} + l_{2} \\sin{\\left(\\theta_{2}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{2}{\\left(t \\right)}\\right) \\cos{\\left(\\theta_{1}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{1}{\\left(t \\right)} - 2 l_{1} \\left(l_{1} \\cos{\\left(\\theta_{1}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{1}{\\left(t \\right)} + l_{2} \\cos{\\left(\\theta_{2}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{2}{\\left(t \\right)}\\right) \\sin{\\left(\\theta_{1}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{1}{\\left(t \\right)}\\right)}{2} + \\frac{m_{2} \\left(2 l_{1} \\left(l_{1} \\sin{\\left(\\theta_{1}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{1}{\\left(t \\right)} + l_{2} \\sin{\\left(\\theta_{2}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{2}{\\left(t \\right)}\\right) \\cos{\\left(\\theta_{1}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{1}{\\left(t \\right)} - 2 l_{1} \\left(l_{1} \\cos{\\left(\\theta_{1}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{1}{\\left(t \\right)} + l_{2} \\cos{\\left(\\theta_{2}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{2}{\\left(t \\right)}\\right) \\sin{\\left(\\theta_{1}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{1}{\\left(t \\right)} + 2 l_{1} \\left(- l_{1} \\sin{\\left(\\theta_{1}{\\left(t \\right)} \\right)} \\left(\\frac{d}{d t} \\theta_{1}{\\left(t \\right)}\\right)^{2} + l_{1} \\cos{\\left(\\theta_{1}{\\left(t \\right)} \\right)} \\frac{d^{2}}{d t^{2}} \\theta_{1}{\\left(t \\right)} - l_{2} \\sin{\\left(\\theta_{2}{\\left(t \\right)} \\right)} \\left(\\frac{d}{d t} \\theta_{2}{\\left(t \\right)}\\right)^{2} + l_{2} \\cos{\\left(\\theta_{2}{\\left(t \\right)} \\right)} \\frac{d^{2}}{d t^{2}} \\theta_{2}{\\left(t \\right)}\\right) \\cos{\\left(\\theta_{1}{\\left(t \\right)} \\right)} + 2 l_{1} \\left(l_{1} \\sin{\\left(\\theta_{1}{\\left(t \\right)} \\right)} \\frac{d^{2}}{d t^{2}} \\theta_{1}{\\left(t \\right)} + l_{1} \\cos{\\left(\\theta_{1}{\\left(t \\right)} \\right)} \\left(\\frac{d}{d t} \\theta_{1}{\\left(t \\right)}\\right)^{2} + l_{2} \\sin{\\left(\\theta_{2}{\\left(t \\right)} \\right)} \\frac{d^{2}}{d t^{2}} \\theta_{2}{\\left(t \\right)} + l_{2} \\cos{\\left(\\theta_{2}{\\left(t \\right)} \\right)} \\left(\\frac{d}{d t} \\theta_{2}{\\left(t \\right)}\\right)^{2}\\right) \\sin{\\left(\\theta_{1}{\\left(t \\right)} \\right)}\\right)}{2} - \\frac{m_{3} \\left(2 l_{1} \\left(l_{1} \\sin{\\left(\\theta_{1}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{1}{\\left(t \\right)} + l_{2} \\sin{\\left(\\theta_{2}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{2}{\\left(t \\right)} + l_{3} \\sin{\\left(\\theta_{3}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{3}{\\left(t \\right)}\\right) \\cos{\\left(\\theta_{1}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{1}{\\left(t \\right)} - 2 l_{1} \\left(l_{1} \\cos{\\left(\\theta_{1}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{1}{\\left(t \\right)} + l_{2} \\cos{\\left(\\theta_{2}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{2}{\\left(t \\right)} + l_{3} \\cos{\\left(\\theta_{3}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{3}{\\left(t \\right)}\\right) \\sin{\\left(\\theta_{1}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{1}{\\left(t \\right)}\\right)}{2} + \\frac{m_{3} \\left(2 l_{1} \\left(l_{1} \\sin{\\left(\\theta_{1}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{1}{\\left(t \\right)} + l_{2} \\sin{\\left(\\theta_{2}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{2}{\\left(t \\right)} + l_{3} \\sin{\\left(\\theta_{3}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{3}{\\left(t \\right)}\\right) \\cos{\\left(\\theta_{1}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{1}{\\left(t \\right)} - 2 l_{1} \\left(l_{1} \\cos{\\left(\\theta_{1}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{1}{\\left(t \\right)} + l_{2} \\cos{\\left(\\theta_{2}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{2}{\\left(t \\right)} + l_{3} \\cos{\\left(\\theta_{3}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{3}{\\left(t \\right)}\\right) \\sin{\\left(\\theta_{1}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{1}{\\left(t \\right)} + 2 l_{1} \\left(- l_{1} \\sin{\\left(\\theta_{1}{\\left(t \\right)} \\right)} \\left(\\frac{d}{d t} \\theta_{1}{\\left(t \\right)}\\right)^{2} + l_{1} \\cos{\\left(\\theta_{1}{\\left(t \\right)} \\right)} \\frac{d^{2}}{d t^{2}} \\theta_{1}{\\left(t \\right)} - l_{2} \\sin{\\left(\\theta_{2}{\\left(t \\right)} \\right)} \\left(\\frac{d}{d t} \\theta_{2}{\\left(t \\right)}\\right)^{2} + l_{2} \\cos{\\left(\\theta_{2}{\\left(t \\right)} \\right)} \\frac{d^{2}}{d t^{2}} \\theta_{2}{\\left(t \\right)} - l_{3} \\sin{\\left(\\theta_{3}{\\left(t \\right)} \\right)} \\left(\\frac{d}{d t} \\theta_{3}{\\left(t \\right)}\\right)^{2} + l_{3} \\cos{\\left(\\theta_{3}{\\left(t \\right)} \\right)} \\frac{d^{2}}{d t^{2}} \\theta_{3}{\\left(t \\right)}\\right) \\cos{\\left(\\theta_{1}{\\left(t \\right)} \\right)} + 2 l_{1} \\left(l_{1} \\sin{\\left(\\theta_{1}{\\left(t \\right)} \\right)} \\frac{d^{2}}{d t^{2}} \\theta_{1}{\\left(t \\right)} + l_{1} \\cos{\\left(\\theta_{1}{\\left(t \\right)} \\right)} \\left(\\frac{d}{d t} \\theta_{1}{\\left(t \\right)}\\right)^{2} + l_{2} \\sin{\\left(\\theta_{2}{\\left(t \\right)} \\right)} \\frac{d^{2}}{d t^{2}} \\theta_{2}{\\left(t \\right)} + l_{2} \\cos{\\left(\\theta_{2}{\\left(t \\right)} \\right)} \\left(\\frac{d}{d t} \\theta_{2}{\\left(t \\right)}\\right)^{2} + l_{3} \\sin{\\left(\\theta_{3}{\\left(t \\right)} \\right)} \\frac{d^{2}}{d t^{2}} \\theta_{3}{\\left(t \\right)} + l_{3} \\cos{\\left(\\theta_{3}{\\left(t \\right)} \\right)} \\left(\\frac{d}{d t} \\theta_{3}{\\left(t \\right)}\\right)^{2}\\right) \\sin{\\left(\\theta_{1}{\\left(t \\right)} \\right)}\\right)}{2} - \\frac{m_{4} \\left(2 l_{1} \\left(l_{1} \\sin{\\left(\\theta_{1}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{1}{\\left(t \\right)} + l_{2} \\sin{\\left(\\theta_{2}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{2}{\\left(t \\right)} + l_{3} \\sin{\\left(\\theta_{3}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{3}{\\left(t \\right)} + l_{4} \\sin{\\left(\\theta_{4}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{4}{\\left(t \\right)}\\right) \\cos{\\left(\\theta_{1}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{1}{\\left(t \\right)} - 2 l_{1} \\left(l_{1} \\cos{\\left(\\theta_{1}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{1}{\\left(t \\right)} + l_{2} \\cos{\\left(\\theta_{2}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{2}{\\left(t \\right)} + l_{3} \\cos{\\left(\\theta_{3}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{3}{\\left(t \\right)} + l_{4} \\cos{\\left(\\theta_{4}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{4}{\\left(t \\right)}\\right) \\sin{\\left(\\theta_{1}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{1}{\\left(t \\right)}\\right)}{2} + \\frac{m_{4} \\left(2 l_{1} \\left(l_{1} \\sin{\\left(\\theta_{1}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{1}{\\left(t \\right)} + l_{2} \\sin{\\left(\\theta_{2}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{2}{\\left(t \\right)} + l_{3} \\sin{\\left(\\theta_{3}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{3}{\\left(t \\right)} + l_{4} \\sin{\\left(\\theta_{4}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{4}{\\left(t \\right)}\\right) \\cos{\\left(\\theta_{1}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{1}{\\left(t \\right)} - 2 l_{1} \\left(l_{1} \\cos{\\left(\\theta_{1}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{1}{\\left(t \\right)} + l_{2} \\cos{\\left(\\theta_{2}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{2}{\\left(t \\right)} + l_{3} \\cos{\\left(\\theta_{3}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{3}{\\left(t \\right)} + l_{4} \\cos{\\left(\\theta_{4}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{4}{\\left(t \\right)}\\right) \\sin{\\left(\\theta_{1}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{1}{\\left(t \\right)} + 2 l_{1} \\left(- l_{1} \\sin{\\left(\\theta_{1}{\\left(t \\right)} \\right)} \\left(\\frac{d}{d t} \\theta_{1}{\\left(t \\right)}\\right)^{2} + l_{1} \\cos{\\left(\\theta_{1}{\\left(t \\right)} \\right)} \\frac{d^{2}}{d t^{2}} \\theta_{1}{\\left(t \\right)} - l_{2} \\sin{\\left(\\theta_{2}{\\left(t \\right)} \\right)} \\left(\\frac{d}{d t} \\theta_{2}{\\left(t \\right)}\\right)^{2} + l_{2} \\cos{\\left(\\theta_{2}{\\left(t \\right)} \\right)} \\frac{d^{2}}{d t^{2}} \\theta_{2}{\\left(t \\right)} - l_{3} \\sin{\\left(\\theta_{3}{\\left(t \\right)} \\right)} \\left(\\frac{d}{d t} \\theta_{3}{\\left(t \\right)}\\right)^{2} + l_{3} \\cos{\\left(\\theta_{3}{\\left(t \\right)} \\right)} \\frac{d^{2}}{d t^{2}} \\theta_{3}{\\left(t \\right)} - l_{4} \\sin{\\left(\\theta_{4}{\\left(t \\right)} \\right)} \\left(\\frac{d}{d t} \\theta_{4}{\\left(t \\right)}\\right)^{2} + l_{4} \\cos{\\left(\\theta_{4}{\\left(t \\right)} \\right)} \\frac{d^{2}}{d t^{2}} \\theta_{4}{\\left(t \\right)}\\right) \\cos{\\left(\\theta_{1}{\\left(t \\right)} \\right)} + 2 l_{1} \\left(l_{1} \\sin{\\left(\\theta_{1}{\\left(t \\right)} \\right)} \\frac{d^{2}}{d t^{2}} \\theta_{1}{\\left(t \\right)} + l_{1} \\cos{\\left(\\theta_{1}{\\left(t \\right)} \\right)} \\left(\\frac{d}{d t} \\theta_{1}{\\left(t \\right)}\\right)^{2} + l_{2} \\sin{\\left(\\theta_{2}{\\left(t \\right)} \\right)} \\frac{d^{2}}{d t^{2}} \\theta_{2}{\\left(t \\right)} + l_{2} \\cos{\\left(\\theta_{2}{\\left(t \\right)} \\right)} \\left(\\frac{d}{d t} \\theta_{2}{\\left(t \\right)}\\right)^{2} + l_{3} \\sin{\\left(\\theta_{3}{\\left(t \\right)} \\right)} \\frac{d^{2}}{d t^{2}} \\theta_{3}{\\left(t \\right)} + l_{3} \\cos{\\left(\\theta_{3}{\\left(t \\right)} \\right)} \\left(\\frac{d}{d t} \\theta_{3}{\\left(t \\right)}\\right)^{2} + l_{4} \\sin{\\left(\\theta_{4}{\\left(t \\right)} \\right)} \\frac{d^{2}}{d t^{2}} \\theta_{4}{\\left(t \\right)} + l_{4} \\cos{\\left(\\theta_{4}{\\left(t \\right)} \\right)} \\left(\\frac{d}{d t} \\theta_{4}{\\left(t \\right)}\\right)^{2}\\right) \\sin{\\left(\\theta_{1}{\\left(t \\right)} \\right)}\\right)}{2}\\\\g l_{2} m_{2} \\sin{\\left(\\theta_{2}{\\left(t \\right)} \\right)} + g l_{2} m_{3} \\sin{\\left(\\theta_{2}{\\left(t \\right)} \\right)} + g l_{2} m_{4} \\sin{\\left(\\theta_{2}{\\left(t \\right)} \\right)} - \\frac{m_{2} \\left(2 l_{2} \\left(l_{1} \\sin{\\left(\\theta_{1}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{1}{\\left(t \\right)} + l_{2} \\sin{\\left(\\theta_{2}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{2}{\\left(t \\right)}\\right) \\cos{\\left(\\theta_{2}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{2}{\\left(t \\right)} - 2 l_{2} \\left(l_{1} \\cos{\\left(\\theta_{1}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{1}{\\left(t \\right)} + l_{2} \\cos{\\left(\\theta_{2}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{2}{\\left(t \\right)}\\right) \\sin{\\left(\\theta_{2}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{2}{\\left(t \\right)}\\right)}{2} + \\frac{m_{2} \\left(2 l_{2} \\left(l_{1} \\sin{\\left(\\theta_{1}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{1}{\\left(t \\right)} + l_{2} \\sin{\\left(\\theta_{2}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{2}{\\left(t \\right)}\\right) \\cos{\\left(\\theta_{2}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{2}{\\left(t \\right)} - 2 l_{2} \\left(l_{1} \\cos{\\left(\\theta_{1}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{1}{\\left(t \\right)} + l_{2} \\cos{\\left(\\theta_{2}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{2}{\\left(t \\right)}\\right) \\sin{\\left(\\theta_{2}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{2}{\\left(t \\right)} + 2 l_{2} \\left(- l_{1} \\sin{\\left(\\theta_{1}{\\left(t \\right)} \\right)} \\left(\\frac{d}{d t} \\theta_{1}{\\left(t \\right)}\\right)^{2} + l_{1} \\cos{\\left(\\theta_{1}{\\left(t \\right)} \\right)} \\frac{d^{2}}{d t^{2}} \\theta_{1}{\\left(t \\right)} - l_{2} \\sin{\\left(\\theta_{2}{\\left(t \\right)} \\right)} \\left(\\frac{d}{d t} \\theta_{2}{\\left(t \\right)}\\right)^{2} + l_{2} \\cos{\\left(\\theta_{2}{\\left(t \\right)} \\right)} \\frac{d^{2}}{d t^{2}} \\theta_{2}{\\left(t \\right)}\\right) \\cos{\\left(\\theta_{2}{\\left(t \\right)} \\right)} + 2 l_{2} \\left(l_{1} \\sin{\\left(\\theta_{1}{\\left(t \\right)} \\right)} \\frac{d^{2}}{d t^{2}} \\theta_{1}{\\left(t \\right)} + l_{1} \\cos{\\left(\\theta_{1}{\\left(t \\right)} \\right)} \\left(\\frac{d}{d t} \\theta_{1}{\\left(t \\right)}\\right)^{2} + l_{2} \\sin{\\left(\\theta_{2}{\\left(t \\right)} \\right)} \\frac{d^{2}}{d t^{2}} \\theta_{2}{\\left(t \\right)} + l_{2} \\cos{\\left(\\theta_{2}{\\left(t \\right)} \\right)} \\left(\\frac{d}{d t} \\theta_{2}{\\left(t \\right)}\\right)^{2}\\right) \\sin{\\left(\\theta_{2}{\\left(t \\right)} \\right)}\\right)}{2} - \\frac{m_{3} \\left(2 l_{2} \\left(l_{1} \\sin{\\left(\\theta_{1}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{1}{\\left(t \\right)} + l_{2} \\sin{\\left(\\theta_{2}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{2}{\\left(t \\right)} + l_{3} \\sin{\\left(\\theta_{3}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{3}{\\left(t \\right)}\\right) \\cos{\\left(\\theta_{2}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{2}{\\left(t \\right)} - 2 l_{2} \\left(l_{1} \\cos{\\left(\\theta_{1}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{1}{\\left(t \\right)} + l_{2} \\cos{\\left(\\theta_{2}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{2}{\\left(t \\right)} + l_{3} \\cos{\\left(\\theta_{3}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{3}{\\left(t \\right)}\\right) \\sin{\\left(\\theta_{2}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{2}{\\left(t \\right)}\\right)}{2} + \\frac{m_{3} \\left(2 l_{2} \\left(l_{1} \\sin{\\left(\\theta_{1}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{1}{\\left(t \\right)} + l_{2} \\sin{\\left(\\theta_{2}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{2}{\\left(t \\right)} + l_{3} \\sin{\\left(\\theta_{3}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{3}{\\left(t \\right)}\\right) \\cos{\\left(\\theta_{2}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{2}{\\left(t \\right)} - 2 l_{2} \\left(l_{1} \\cos{\\left(\\theta_{1}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{1}{\\left(t \\right)} + l_{2} \\cos{\\left(\\theta_{2}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{2}{\\left(t \\right)} + l_{3} \\cos{\\left(\\theta_{3}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{3}{\\left(t \\right)}\\right) \\sin{\\left(\\theta_{2}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{2}{\\left(t \\right)} + 2 l_{2} \\left(- l_{1} \\sin{\\left(\\theta_{1}{\\left(t \\right)} \\right)} \\left(\\frac{d}{d t} \\theta_{1}{\\left(t \\right)}\\right)^{2} + l_{1} \\cos{\\left(\\theta_{1}{\\left(t \\right)} \\right)} \\frac{d^{2}}{d t^{2}} \\theta_{1}{\\left(t \\right)} - l_{2} \\sin{\\left(\\theta_{2}{\\left(t \\right)} \\right)} \\left(\\frac{d}{d t} \\theta_{2}{\\left(t \\right)}\\right)^{2} + l_{2} \\cos{\\left(\\theta_{2}{\\left(t \\right)} \\right)} \\frac{d^{2}}{d t^{2}} \\theta_{2}{\\left(t \\right)} - l_{3} \\sin{\\left(\\theta_{3}{\\left(t \\right)} \\right)} \\left(\\frac{d}{d t} \\theta_{3}{\\left(t \\right)}\\right)^{2} + l_{3} \\cos{\\left(\\theta_{3}{\\left(t \\right)} \\right)} \\frac{d^{2}}{d t^{2}} \\theta_{3}{\\left(t \\right)}\\right) \\cos{\\left(\\theta_{2}{\\left(t \\right)} \\right)} + 2 l_{2} \\left(l_{1} \\sin{\\left(\\theta_{1}{\\left(t \\right)} \\right)} \\frac{d^{2}}{d t^{2}} \\theta_{1}{\\left(t \\right)} + l_{1} \\cos{\\left(\\theta_{1}{\\left(t \\right)} \\right)} \\left(\\frac{d}{d t} \\theta_{1}{\\left(t \\right)}\\right)^{2} + l_{2} \\sin{\\left(\\theta_{2}{\\left(t \\right)} \\right)} \\frac{d^{2}}{d t^{2}} \\theta_{2}{\\left(t \\right)} + l_{2} \\cos{\\left(\\theta_{2}{\\left(t \\right)} \\right)} \\left(\\frac{d}{d t} \\theta_{2}{\\left(t \\right)}\\right)^{2} + l_{3} \\sin{\\left(\\theta_{3}{\\left(t \\right)} \\right)} \\frac{d^{2}}{d t^{2}} \\theta_{3}{\\left(t \\right)} + l_{3} \\cos{\\left(\\theta_{3}{\\left(t \\right)} \\right)} \\left(\\frac{d}{d t} \\theta_{3}{\\left(t \\right)}\\right)^{2}\\right) \\sin{\\left(\\theta_{2}{\\left(t \\right)} \\right)}\\right)}{2} - \\frac{m_{4} \\left(2 l_{2} \\left(l_{1} \\sin{\\left(\\theta_{1}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{1}{\\left(t \\right)} + l_{2} \\sin{\\left(\\theta_{2}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{2}{\\left(t \\right)} + l_{3} \\sin{\\left(\\theta_{3}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{3}{\\left(t \\right)} + l_{4} \\sin{\\left(\\theta_{4}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{4}{\\left(t \\right)}\\right) \\cos{\\left(\\theta_{2}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{2}{\\left(t \\right)} - 2 l_{2} \\left(l_{1} \\cos{\\left(\\theta_{1}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{1}{\\left(t \\right)} + l_{2} \\cos{\\left(\\theta_{2}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{2}{\\left(t \\right)} + l_{3} \\cos{\\left(\\theta_{3}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{3}{\\left(t \\right)} + l_{4} \\cos{\\left(\\theta_{4}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{4}{\\left(t \\right)}\\right) \\sin{\\left(\\theta_{2}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{2}{\\left(t \\right)}\\right)}{2} + \\frac{m_{4} \\left(2 l_{2} \\left(l_{1} \\sin{\\left(\\theta_{1}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{1}{\\left(t \\right)} + l_{2} \\sin{\\left(\\theta_{2}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{2}{\\left(t \\right)} + l_{3} \\sin{\\left(\\theta_{3}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{3}{\\left(t \\right)} + l_{4} \\sin{\\left(\\theta_{4}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{4}{\\left(t \\right)}\\right) \\cos{\\left(\\theta_{2}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{2}{\\left(t \\right)} - 2 l_{2} \\left(l_{1} \\cos{\\left(\\theta_{1}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{1}{\\left(t \\right)} + l_{2} \\cos{\\left(\\theta_{2}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{2}{\\left(t \\right)} + l_{3} \\cos{\\left(\\theta_{3}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{3}{\\left(t \\right)} + l_{4} \\cos{\\left(\\theta_{4}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{4}{\\left(t \\right)}\\right) \\sin{\\left(\\theta_{2}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{2}{\\left(t \\right)} + 2 l_{2} \\left(- l_{1} \\sin{\\left(\\theta_{1}{\\left(t \\right)} \\right)} \\left(\\frac{d}{d t} \\theta_{1}{\\left(t \\right)}\\right)^{2} + l_{1} \\cos{\\left(\\theta_{1}{\\left(t \\right)} \\right)} \\frac{d^{2}}{d t^{2}} \\theta_{1}{\\left(t \\right)} - l_{2} \\sin{\\left(\\theta_{2}{\\left(t \\right)} \\right)} \\left(\\frac{d}{d t} \\theta_{2}{\\left(t \\right)}\\right)^{2} + l_{2} \\cos{\\left(\\theta_{2}{\\left(t \\right)} \\right)} \\frac{d^{2}}{d t^{2}} \\theta_{2}{\\left(t \\right)} - l_{3} \\sin{\\left(\\theta_{3}{\\left(t \\right)} \\right)} \\left(\\frac{d}{d t} \\theta_{3}{\\left(t \\right)}\\right)^{2} + l_{3} \\cos{\\left(\\theta_{3}{\\left(t \\right)} \\right)} \\frac{d^{2}}{d t^{2}} \\theta_{3}{\\left(t \\right)} - l_{4} \\sin{\\left(\\theta_{4}{\\left(t \\right)} \\right)} \\left(\\frac{d}{d t} \\theta_{4}{\\left(t \\right)}\\right)^{2} + l_{4} \\cos{\\left(\\theta_{4}{\\left(t \\right)} \\right)} \\frac{d^{2}}{d t^{2}} \\theta_{4}{\\left(t \\right)}\\right) \\cos{\\left(\\theta_{2}{\\left(t \\right)} \\right)} + 2 l_{2} \\left(l_{1} \\sin{\\left(\\theta_{1}{\\left(t \\right)} \\right)} \\frac{d^{2}}{d t^{2}} \\theta_{1}{\\left(t \\right)} + l_{1} \\cos{\\left(\\theta_{1}{\\left(t \\right)} \\right)} \\left(\\frac{d}{d t} \\theta_{1}{\\left(t \\right)}\\right)^{2} + l_{2} \\sin{\\left(\\theta_{2}{\\left(t \\right)} \\right)} \\frac{d^{2}}{d t^{2}} \\theta_{2}{\\left(t \\right)} + l_{2} \\cos{\\left(\\theta_{2}{\\left(t \\right)} \\right)} \\left(\\frac{d}{d t} \\theta_{2}{\\left(t \\right)}\\right)^{2} + l_{3} \\sin{\\left(\\theta_{3}{\\left(t \\right)} \\right)} \\frac{d^{2}}{d t^{2}} \\theta_{3}{\\left(t \\right)} + l_{3} \\cos{\\left(\\theta_{3}{\\left(t \\right)} \\right)} \\left(\\frac{d}{d t} \\theta_{3}{\\left(t \\right)}\\right)^{2} + l_{4} \\sin{\\left(\\theta_{4}{\\left(t \\right)} \\right)} \\frac{d^{2}}{d t^{2}} \\theta_{4}{\\left(t \\right)} + l_{4} \\cos{\\left(\\theta_{4}{\\left(t \\right)} \\right)} \\left(\\frac{d}{d t} \\theta_{4}{\\left(t \\right)}\\right)^{2}\\right) \\sin{\\left(\\theta_{2}{\\left(t \\right)} \\right)}\\right)}{2}\\\\g l_{3} m_{3} \\sin{\\left(\\theta_{3}{\\left(t \\right)} \\right)} + g l_{3} m_{4} \\sin{\\left(\\theta_{3}{\\left(t \\right)} \\right)} - \\frac{m_{3} \\left(2 l_{3} \\left(l_{1} \\sin{\\left(\\theta_{1}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{1}{\\left(t \\right)} + l_{2} \\sin{\\left(\\theta_{2}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{2}{\\left(t \\right)} + l_{3} \\sin{\\left(\\theta_{3}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{3}{\\left(t \\right)}\\right) \\cos{\\left(\\theta_{3}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{3}{\\left(t \\right)} - 2 l_{3} \\left(l_{1} \\cos{\\left(\\theta_{1}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{1}{\\left(t \\right)} + l_{2} \\cos{\\left(\\theta_{2}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{2}{\\left(t \\right)} + l_{3} \\cos{\\left(\\theta_{3}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{3}{\\left(t \\right)}\\right) \\sin{\\left(\\theta_{3}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{3}{\\left(t \\right)}\\right)}{2} + \\frac{m_{3} \\left(2 l_{3} \\left(l_{1} \\sin{\\left(\\theta_{1}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{1}{\\left(t \\right)} + l_{2} \\sin{\\left(\\theta_{2}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{2}{\\left(t \\right)} + l_{3} \\sin{\\left(\\theta_{3}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{3}{\\left(t \\right)}\\right) \\cos{\\left(\\theta_{3}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{3}{\\left(t \\right)} - 2 l_{3} \\left(l_{1} \\cos{\\left(\\theta_{1}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{1}{\\left(t \\right)} + l_{2} \\cos{\\left(\\theta_{2}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{2}{\\left(t \\right)} + l_{3} \\cos{\\left(\\theta_{3}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{3}{\\left(t \\right)}\\right) \\sin{\\left(\\theta_{3}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{3}{\\left(t \\right)} + 2 l_{3} \\left(- l_{1} \\sin{\\left(\\theta_{1}{\\left(t \\right)} \\right)} \\left(\\frac{d}{d t} \\theta_{1}{\\left(t \\right)}\\right)^{2} + l_{1} \\cos{\\left(\\theta_{1}{\\left(t \\right)} \\right)} \\frac{d^{2}}{d t^{2}} \\theta_{1}{\\left(t \\right)} - l_{2} \\sin{\\left(\\theta_{2}{\\left(t \\right)} \\right)} \\left(\\frac{d}{d t} \\theta_{2}{\\left(t \\right)}\\right)^{2} + l_{2} \\cos{\\left(\\theta_{2}{\\left(t \\right)} \\right)} \\frac{d^{2}}{d t^{2}} \\theta_{2}{\\left(t \\right)} - l_{3} \\sin{\\left(\\theta_{3}{\\left(t \\right)} \\right)} \\left(\\frac{d}{d t} \\theta_{3}{\\left(t \\right)}\\right)^{2} + l_{3} \\cos{\\left(\\theta_{3}{\\left(t \\right)} \\right)} \\frac{d^{2}}{d t^{2}} \\theta_{3}{\\left(t \\right)}\\right) \\cos{\\left(\\theta_{3}{\\left(t \\right)} \\right)} + 2 l_{3} \\left(l_{1} \\sin{\\left(\\theta_{1}{\\left(t \\right)} \\right)} \\frac{d^{2}}{d t^{2}} \\theta_{1}{\\left(t \\right)} + l_{1} \\cos{\\left(\\theta_{1}{\\left(t \\right)} \\right)} \\left(\\frac{d}{d t} \\theta_{1}{\\left(t \\right)}\\right)^{2} + l_{2} \\sin{\\left(\\theta_{2}{\\left(t \\right)} \\right)} \\frac{d^{2}}{d t^{2}} \\theta_{2}{\\left(t \\right)} + l_{2} \\cos{\\left(\\theta_{2}{\\left(t \\right)} \\right)} \\left(\\frac{d}{d t} \\theta_{2}{\\left(t \\right)}\\right)^{2} + l_{3} \\sin{\\left(\\theta_{3}{\\left(t \\right)} \\right)} \\frac{d^{2}}{d t^{2}} \\theta_{3}{\\left(t \\right)} + l_{3} \\cos{\\left(\\theta_{3}{\\left(t \\right)} \\right)} \\left(\\frac{d}{d t} \\theta_{3}{\\left(t \\right)}\\right)^{2}\\right) \\sin{\\left(\\theta_{3}{\\left(t \\right)} \\right)}\\right)}{2} - \\frac{m_{4} \\left(2 l_{3} \\left(l_{1} \\sin{\\left(\\theta_{1}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{1}{\\left(t \\right)} + l_{2} \\sin{\\left(\\theta_{2}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{2}{\\left(t \\right)} + l_{3} \\sin{\\left(\\theta_{3}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{3}{\\left(t \\right)} + l_{4} \\sin{\\left(\\theta_{4}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{4}{\\left(t \\right)}\\right) \\cos{\\left(\\theta_{3}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{3}{\\left(t \\right)} - 2 l_{3} \\left(l_{1} \\cos{\\left(\\theta_{1}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{1}{\\left(t \\right)} + l_{2} \\cos{\\left(\\theta_{2}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{2}{\\left(t \\right)} + l_{3} \\cos{\\left(\\theta_{3}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{3}{\\left(t \\right)} + l_{4} \\cos{\\left(\\theta_{4}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{4}{\\left(t \\right)}\\right) \\sin{\\left(\\theta_{3}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{3}{\\left(t \\right)}\\right)}{2} + \\frac{m_{4} \\left(2 l_{3} \\left(l_{1} \\sin{\\left(\\theta_{1}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{1}{\\left(t \\right)} + l_{2} \\sin{\\left(\\theta_{2}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{2}{\\left(t \\right)} + l_{3} \\sin{\\left(\\theta_{3}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{3}{\\left(t \\right)} + l_{4} \\sin{\\left(\\theta_{4}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{4}{\\left(t \\right)}\\right) \\cos{\\left(\\theta_{3}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{3}{\\left(t \\right)} - 2 l_{3} \\left(l_{1} \\cos{\\left(\\theta_{1}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{1}{\\left(t \\right)} + l_{2} \\cos{\\left(\\theta_{2}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{2}{\\left(t \\right)} + l_{3} \\cos{\\left(\\theta_{3}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{3}{\\left(t \\right)} + l_{4} \\cos{\\left(\\theta_{4}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{4}{\\left(t \\right)}\\right) \\sin{\\left(\\theta_{3}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{3}{\\left(t \\right)} + 2 l_{3} \\left(- l_{1} \\sin{\\left(\\theta_{1}{\\left(t \\right)} \\right)} \\left(\\frac{d}{d t} \\theta_{1}{\\left(t \\right)}\\right)^{2} + l_{1} \\cos{\\left(\\theta_{1}{\\left(t \\right)} \\right)} \\frac{d^{2}}{d t^{2}} \\theta_{1}{\\left(t \\right)} - l_{2} \\sin{\\left(\\theta_{2}{\\left(t \\right)} \\right)} \\left(\\frac{d}{d t} \\theta_{2}{\\left(t \\right)}\\right)^{2} + l_{2} \\cos{\\left(\\theta_{2}{\\left(t \\right)} \\right)} \\frac{d^{2}}{d t^{2}} \\theta_{2}{\\left(t \\right)} - l_{3} \\sin{\\left(\\theta_{3}{\\left(t \\right)} \\right)} \\left(\\frac{d}{d t} \\theta_{3}{\\left(t \\right)}\\right)^{2} + l_{3} \\cos{\\left(\\theta_{3}{\\left(t \\right)} \\right)} \\frac{d^{2}}{d t^{2}} \\theta_{3}{\\left(t \\right)} - l_{4} \\sin{\\left(\\theta_{4}{\\left(t \\right)} \\right)} \\left(\\frac{d}{d t} \\theta_{4}{\\left(t \\right)}\\right)^{2} + l_{4} \\cos{\\left(\\theta_{4}{\\left(t \\right)} \\right)} \\frac{d^{2}}{d t^{2}} \\theta_{4}{\\left(t \\right)}\\right) \\cos{\\left(\\theta_{3}{\\left(t \\right)} \\right)} + 2 l_{3} \\left(l_{1} \\sin{\\left(\\theta_{1}{\\left(t \\right)} \\right)} \\frac{d^{2}}{d t^{2}} \\theta_{1}{\\left(t \\right)} + l_{1} \\cos{\\left(\\theta_{1}{\\left(t \\right)} \\right)} \\left(\\frac{d}{d t} \\theta_{1}{\\left(t \\right)}\\right)^{2} + l_{2} \\sin{\\left(\\theta_{2}{\\left(t \\right)} \\right)} \\frac{d^{2}}{d t^{2}} \\theta_{2}{\\left(t \\right)} + l_{2} \\cos{\\left(\\theta_{2}{\\left(t \\right)} \\right)} \\left(\\frac{d}{d t} \\theta_{2}{\\left(t \\right)}\\right)^{2} + l_{3} \\sin{\\left(\\theta_{3}{\\left(t \\right)} \\right)} \\frac{d^{2}}{d t^{2}} \\theta_{3}{\\left(t \\right)} + l_{3} \\cos{\\left(\\theta_{3}{\\left(t \\right)} \\right)} \\left(\\frac{d}{d t} \\theta_{3}{\\left(t \\right)}\\right)^{2} + l_{4} \\sin{\\left(\\theta_{4}{\\left(t \\right)} \\right)} \\frac{d^{2}}{d t^{2}} \\theta_{4}{\\left(t \\right)} + l_{4} \\cos{\\left(\\theta_{4}{\\left(t \\right)} \\right)} \\left(\\frac{d}{d t} \\theta_{4}{\\left(t \\right)}\\right)^{2}\\right) \\sin{\\left(\\theta_{3}{\\left(t \\right)} \\right)}\\right)}{2}\\\\g l_{4} m_{4} \\sin{\\left(\\theta_{4}{\\left(t \\right)} \\right)} - \\frac{m_{4} \\left(2 l_{4} \\left(l_{1} \\sin{\\left(\\theta_{1}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{1}{\\left(t \\right)} + l_{2} \\sin{\\left(\\theta_{2}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{2}{\\left(t \\right)} + l_{3} \\sin{\\left(\\theta_{3}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{3}{\\left(t \\right)} + l_{4} \\sin{\\left(\\theta_{4}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{4}{\\left(t \\right)}\\right) \\cos{\\left(\\theta_{4}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{4}{\\left(t \\right)} - 2 l_{4} \\left(l_{1} \\cos{\\left(\\theta_{1}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{1}{\\left(t \\right)} + l_{2} \\cos{\\left(\\theta_{2}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{2}{\\left(t \\right)} + l_{3} \\cos{\\left(\\theta_{3}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{3}{\\left(t \\right)} + l_{4} \\cos{\\left(\\theta_{4}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{4}{\\left(t \\right)}\\right) \\sin{\\left(\\theta_{4}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{4}{\\left(t \\right)}\\right)}{2} + \\frac{m_{4} \\left(2 l_{4} \\left(l_{1} \\sin{\\left(\\theta_{1}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{1}{\\left(t \\right)} + l_{2} \\sin{\\left(\\theta_{2}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{2}{\\left(t \\right)} + l_{3} \\sin{\\left(\\theta_{3}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{3}{\\left(t \\right)} + l_{4} \\sin{\\left(\\theta_{4}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{4}{\\left(t \\right)}\\right) \\cos{\\left(\\theta_{4}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{4}{\\left(t \\right)} - 2 l_{4} \\left(l_{1} \\cos{\\left(\\theta_{1}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{1}{\\left(t \\right)} + l_{2} \\cos{\\left(\\theta_{2}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{2}{\\left(t \\right)} + l_{3} \\cos{\\left(\\theta_{3}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{3}{\\left(t \\right)} + l_{4} \\cos{\\left(\\theta_{4}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{4}{\\left(t \\right)}\\right) \\sin{\\left(\\theta_{4}{\\left(t \\right)} \\right)} \\frac{d}{d t} \\theta_{4}{\\left(t \\right)} + 2 l_{4} \\left(- l_{1} \\sin{\\left(\\theta_{1}{\\left(t \\right)} \\right)} \\left(\\frac{d}{d t} \\theta_{1}{\\left(t \\right)}\\right)^{2} + l_{1} \\cos{\\left(\\theta_{1}{\\left(t \\right)} \\right)} \\frac{d^{2}}{d t^{2}} \\theta_{1}{\\left(t \\right)} - l_{2} \\sin{\\left(\\theta_{2}{\\left(t \\right)} \\right)} \\left(\\frac{d}{d t} \\theta_{2}{\\left(t \\right)}\\right)^{2} + l_{2} \\cos{\\left(\\theta_{2}{\\left(t \\right)} \\right)} \\frac{d^{2}}{d t^{2}} \\theta_{2}{\\left(t \\right)} - l_{3} \\sin{\\left(\\theta_{3}{\\left(t \\right)} \\right)} \\left(\\frac{d}{d t} \\theta_{3}{\\left(t \\right)}\\right)^{2} + l_{3} \\cos{\\left(\\theta_{3}{\\left(t \\right)} \\right)} \\frac{d^{2}}{d t^{2}} \\theta_{3}{\\left(t \\right)} - l_{4} \\sin{\\left(\\theta_{4}{\\left(t \\right)} \\right)} \\left(\\frac{d}{d t} \\theta_{4}{\\left(t \\right)}\\right)^{2} + l_{4} \\cos{\\left(\\theta_{4}{\\left(t \\right)} \\right)} \\frac{d^{2}}{d t^{2}} \\theta_{4}{\\left(t \\right)}\\right) \\cos{\\left(\\theta_{4}{\\left(t \\right)} \\right)} + 2 l_{4} \\left(l_{1} \\sin{\\left(\\theta_{1}{\\left(t \\right)} \\right)} \\frac{d^{2}}{d t^{2}} \\theta_{1}{\\left(t \\right)} + l_{1} \\cos{\\left(\\theta_{1}{\\left(t \\right)} \\right)} \\left(\\frac{d}{d t} \\theta_{1}{\\left(t \\right)}\\right)^{2} + l_{2} \\sin{\\left(\\theta_{2}{\\left(t \\right)} \\right)} \\frac{d^{2}}{d t^{2}} \\theta_{2}{\\left(t \\right)} + l_{2} \\cos{\\left(\\theta_{2}{\\left(t \\right)} \\right)} \\left(\\frac{d}{d t} \\theta_{2}{\\left(t \\right)}\\right)^{2} + l_{3} \\sin{\\left(\\theta_{3}{\\left(t \\right)} \\right)} \\frac{d^{2}}{d t^{2}} \\theta_{3}{\\left(t \\right)} + l_{3} \\cos{\\left(\\theta_{3}{\\left(t \\right)} \\right)} \\left(\\frac{d}{d t} \\theta_{3}{\\left(t \\right)}\\right)^{2} + l_{4} \\sin{\\left(\\theta_{4}{\\left(t \\right)} \\right)} \\frac{d^{2}}{d t^{2}} \\theta_{4}{\\left(t \\right)} + l_{4} \\cos{\\left(\\theta_{4}{\\left(t \\right)} \\right)} \\left(\\frac{d}{d t} \\theta_{4}{\\left(t \\right)}\\right)^{2}\\right) \\sin{\\left(\\theta_{4}{\\left(t \\right)} \\right)}\\right)}{2}\\end{matrix}\\right]'




```python
soln1 = sp.simplify(soln[0])
soln2 = sp.simplify(soln[1])
soln3 = sp.simplify(soln[2])
soln4 = sp.simplify(soln[3])
```


```python
solution = sp.solve([soln1, soln2, soln3, soln4], (ddv1, ddv2, ddv3, ddv4))
```


```python
sp.latex(solution)
```


```python

```

a102887227a83a26310f0ac0b516b4cfd49a837b
ipynb
Jupyter Notebook
Pendula/Simple/4Pendulum/QuadruplePendulum.ipynb
ethank5149/Classical-Mechanics
4684cc91abcf65a684237c6ec21246d5cebd232a
MIT
Pendula/Simple/4Pendulum/QuadruplePendulum.ipynb
ethank5149/Classical-Mechanics
4684cc91abcf65a684237c6ec21246d5cebd232a
MIT
Pendula/Simple/4Pendulum/QuadruplePendulum.ipynb
ethank5149/Classical-Mechanics
4684cc91abcf65a684237c6ec21246d5cebd232a
MIT
Qwen/Qwen-72B
1. YES
2. YES