```python
%matplotlib inline
import sympy.physics.mechanics as mech
from sympy import S,Rational,pi
import sympy as sp
```


```python
l1,l2,l3= sp.symbols(r'l1:4')
m1,m2,m3= sp.symbols(r'm1:4')
l,t,m,g= sp.symbols(r'l t m g')
q1,q2,q3 = mech.dynamicsymbols(r'q1:4')
q1d,q2d,q3d = mech.dynamicsymbols(r'q1:4', 1)

# Create and initialize the reference frame
N = mech.ReferenceFrame('N')
pointN = mech.Point('N*')
pointN.set_vel(N, 0)

# Create the points
point1 = pointN.locatenew('point_1', l1*(sp.sin(q1)*N.x-sp.cos(q1)*N.y))
point2 = point1.locatenew('point_2', l2*(sp.sin(q2)*N.x-sp.cos(q2)*N.y))
point3 = point2.locatenew('point_3', l3*(sp.sin(q3)*N.x-sp.cos(q3)*N.y))

# Set the points' velocities
point1.set_vel(N, point1.pos_from(pointN).dt(N))
point2.set_vel(N, point2.pos_from(pointN).dt(N))
point3.set_vel(N, point3.pos_from(pointN).dt(N))

# Create the particles
particle1 = mech.Particle('Particle_1',point1,m1)
particle2 = mech.Particle('Particle_2',point2,m2)
particle3 = mech.Particle('Particle_3',point3,m3)

# Set the particles' potential energy

# Define forces
forces=[(point1,-particle1.mass*g*N.y),(point2,-particle2.mass*g*N.y),(point3,-particle3.mass*g*N.y)]

# Construct the Lagrangian
L = mech.Lagrangian(N, particle1,particle2,particle3)

# Create the LagrangesMethod object
LM = mech.LagrangesMethod(L, [q1,q2,q3], hol_coneqs=None, forcelist=forces, frame=N)

# Form Lagranges Equations
ELeqns = LM.form_lagranges_equations()
ELeqns
```




$\displaystyle \left[\begin{matrix}g l_{1} m_{1} \sin{\left(\operatorname{q_{1}}{\left(t \right)} \right)} + g l_{1} m_{2} \sin{\left(\operatorname{q_{1}}{\left(t \right)} \right)} + g l_{1} m_{3} \sin{\left(\operatorname{q_{1}}{\left(t \right)} \right)} + l_{1}^{2} m_{1} \sin^{2}{\left(\operatorname{q_{1}}{\left(t \right)} \right)} \frac{d^{2}}{d t^{2}} \operatorname{q_{1}}{\left(t \right)} + l_{1}^{2} m_{1} \cos^{2}{\left(\operatorname{q_{1}}{\left(t \right)} \right)} \frac{d^{2}}{d t^{2}} \operatorname{q_{1}}{\left(t \right)} + l_{1} m_{2} \left(- l_{1} \sin{\left(\operatorname{q_{1}}{\left(t \right)} \right)} \left(\frac{d}{d t} \operatorname{q_{1}}{\left(t \right)}\right)^{2} + l_{1} \cos{\left(\operatorname{q_{1}}{\left(t \right)} \right)} \frac{d^{2}}{d t^{2}} \operatorname{q_{1}}{\left(t \right)} - l_{2} \sin{\left(\operatorname{q_{2}}{\left(t \right)} \right)} \left(\frac{d}{d t} \operatorname{q_{2}}{\left(t \right)}\right)^{2} + l_{2} \cos{\left(\operatorname{q_{2}}{\left(t \right)} \right)} \frac{d^{2}}{d t^{2}} \operatorname{q_{2}}{\left(t \right)}\right) \cos{\left(\operatorname{q_{1}}{\left(t \right)} \right)} + l_{1} m_{2} \left(l_{1} \sin{\left(\operatorname{q_{1}}{\left(t \right)} \right)} \frac{d^{2}}{d t^{2}} \operatorname{q_{1}}{\left(t \right)} + l_{1} \cos{\left(\operatorname{q_{1}}{\left(t \right)} \right)} \left(\frac{d}{d t} \operatorname{q_{1}}{\left(t \right)}\right)^{2} + l_{2} \sin{\left(\operatorname{q_{2}}{\left(t \right)} \right)} \frac{d^{2}}{d t^{2}} \operatorname{q_{2}}{\left(t \right)} + l_{2} \cos{\left(\operatorname{q_{2}}{\left(t \right)} \right)} \left(\frac{d}{d t} \operatorname{q_{2}}{\left(t \right)}\right)^{2}\right) \sin{\left(\operatorname{q_{1}}{\left(t \right)} \right)} + l_{1} m_{3} \left(- l_{1} \sin{\left(\operatorname{q_{1}}{\left(t \right)} \right)} \left(\frac{d}{d t} \operatorname{q_{1}}{\left(t \right)}\right)^{2} + l_{1} \cos{\left(\operatorname{q_{1}}{\left(t \right)} \right)} \frac{d^{2}}{d t^{2}} \operatorname{q_{1}}{\left(t \right)} - l_{2} \sin{\left(\operatorname{q_{2}}{\left(t \right)} \right)} \left(\frac{d}{d t} \operatorname{q_{2}}{\left(t \right)}\right)^{2} + l_{2} \cos{\left(\operatorname{q_{2}}{\left(t \right)} \right)} \frac{d^{2}}{d t^{2}} \operatorname{q_{2}}{\left(t \right)} - l_{3} \sin{\left(\operatorname{q_{3}}{\left(t \right)} \right)} \left(\frac{d}{d t} \operatorname{q_{3}}{\left(t \right)}\right)^{2} + l_{3} \cos{\left(\operatorname{q_{3}}{\left(t \right)} \right)} \frac{d^{2}}{d t^{2}} \operatorname{q_{3}}{\left(t \right)}\right) \cos{\left(\operatorname{q_{1}}{\left(t \right)} \right)} + l_{1} m_{3} \left(l_{1} \sin{\left(\operatorname{q_{1}}{\left(t \right)} \right)} \frac{d^{2}}{d t^{2}} \operatorname{q_{1}}{\left(t \right)} + l_{1} \cos{\left(\operatorname{q_{1}}{\left(t \right)} \right)} \left(\frac{d}{d t} \operatorname{q_{1}}{\left(t \right)}\right)^{2} + l_{2} \sin{\left(\operatorname{q_{2}}{\left(t \right)} \right)} \frac{d^{2}}{d t^{2}} \operatorname{q_{2}}{\left(t \right)} + l_{2} \cos{\left(\operatorname{q_{2}}{\left(t \right)} \right)} \left(\frac{d}{d t} \operatorname{q_{2}}{\left(t \right)}\right)^{2} + l_{3} \sin{\left(\operatorname{q_{3}}{\left(t \right)} \right)} \frac{d^{2}}{d t^{2}} \operatorname{q_{3}}{\left(t \right)} + l_{3} \cos{\left(\operatorname{q_{3}}{\left(t \right)} \right)} \left(\frac{d}{d t} \operatorname{q_{3}}{\left(t \right)}\right)^{2}\right) \sin{\left(\operatorname{q_{1}}{\left(t \right)} \right)}\\g l_{2} m_{2} \sin{\left(\operatorname{q_{2}}{\left(t \right)} \right)} + g l_{2} m_{3} \sin{\left(\operatorname{q_{2}}{\left(t \right)} \right)} + l_{2} m_{2} \left(- l_{1} \sin{\left(\operatorname{q_{1}}{\left(t \right)} \right)} \left(\frac{d}{d t} \operatorname{q_{1}}{\left(t \right)}\right)^{2} + l_{1} \cos{\left(\operatorname{q_{1}}{\left(t \right)} \right)} \frac{d^{2}}{d t^{2}} \operatorname{q_{1}}{\left(t \right)} - l_{2} \sin{\left(\operatorname{q_{2}}{\left(t \right)} \right)} \left(\frac{d}{d t} \operatorname{q_{2}}{\left(t \right)}\right)^{2} + l_{2} \cos{\left(\operatorname{q_{2}}{\left(t \right)} \right)} \frac{d^{2}}{d t^{2}} \operatorname{q_{2}}{\left(t \right)}\right) \cos{\left(\operatorname{q_{2}}{\left(t \right)} \right)} + l_{2} m_{2} \left(l_{1} \sin{\left(\operatorname{q_{1}}{\left(t \right)} \right)} \frac{d^{2}}{d t^{2}} \operatorname{q_{1}}{\left(t \right)} + l_{1} \cos{\left(\operatorname{q_{1}}{\left(t \right)} \right)} \left(\frac{d}{d t} \operatorname{q_{1}}{\left(t \right)}\right)^{2} + l_{2} \sin{\left(\operatorname{q_{2}}{\left(t \right)} \right)} \frac{d^{2}}{d t^{2}} \operatorname{q_{2}}{\left(t \right)} + l_{2} \cos{\left(\operatorname{q_{2}}{\left(t \right)} \right)} \left(\frac{d}{d t} \operatorname{q_{2}}{\left(t \right)}\right)^{2}\right) \sin{\left(\operatorname{q_{2}}{\left(t \right)} \right)} + l_{2} m_{3} \left(- l_{1} \sin{\left(\operatorname{q_{1}}{\left(t \right)} \right)} \left(\frac{d}{d t} \operatorname{q_{1}}{\left(t \right)}\right)^{2} + l_{1} \cos{\left(\operatorname{q_{1}}{\left(t \right)} \right)} \frac{d^{2}}{d t^{2}} \operatorname{q_{1}}{\left(t \right)} - l_{2} \sin{\left(\operatorname{q_{2}}{\left(t \right)} \right)} \left(\frac{d}{d t} \operatorname{q_{2}}{\left(t \right)}\right)^{2} + l_{2} \cos{\left(\operatorname{q_{2}}{\left(t \right)} \right)} \frac{d^{2}}{d t^{2}} \operatorname{q_{2}}{\left(t \right)} - l_{3} \sin{\left(\operatorname{q_{3}}{\left(t \right)} \right)} \left(\frac{d}{d t} \operatorname{q_{3}}{\left(t \right)}\right)^{2} + l_{3} \cos{\left(\operatorname{q_{3}}{\left(t \right)} \right)} \frac{d^{2}}{d t^{2}} \operatorname{q_{3}}{\left(t \right)}\right) \cos{\left(\operatorname{q_{2}}{\left(t \right)} \right)} + l_{2} m_{3} \left(l_{1} \sin{\left(\operatorname{q_{1}}{\left(t \right)} \right)} \frac{d^{2}}{d t^{2}} \operatorname{q_{1}}{\left(t \right)} + l_{1} \cos{\left(\operatorname{q_{1}}{\left(t \right)} \right)} \left(\frac{d}{d t} \operatorname{q_{1}}{\left(t \right)}\right)^{2} + l_{2} \sin{\left(\operatorname{q_{2}}{\left(t \right)} \right)} \frac{d^{2}}{d t^{2}} \operatorname{q_{2}}{\left(t \right)} + l_{2} \cos{\left(\operatorname{q_{2}}{\left(t \right)} \right)} \left(\frac{d}{d t} \operatorname{q_{2}}{\left(t \right)}\right)^{2} + l_{3} \sin{\left(\operatorname{q_{3}}{\left(t \right)} \right)} \frac{d^{2}}{d t^{2}} \operatorname{q_{3}}{\left(t \right)} + l_{3} \cos{\left(\operatorname{q_{3}}{\left(t \right)} \right)} \left(\frac{d}{d t} \operatorname{q_{3}}{\left(t \right)}\right)^{2}\right) \sin{\left(\operatorname{q_{2}}{\left(t \right)} \right)}\\g l_{3} m_{3} \sin{\left(\operatorname{q_{3}}{\left(t \right)} \right)} + l_{3} m_{3} \left(- l_{1} \sin{\left(\operatorname{q_{1}}{\left(t \right)} \right)} \left(\frac{d}{d t} \operatorname{q_{1}}{\left(t \right)}\right)^{2} + l_{1} \cos{\left(\operatorname{q_{1}}{\left(t \right)} \right)} \frac{d^{2}}{d t^{2}} \operatorname{q_{1}}{\left(t \right)} - l_{2} \sin{\left(\operatorname{q_{2}}{\left(t \right)} \right)} \left(\frac{d}{d t} \operatorname{q_{2}}{\left(t \right)}\right)^{2} + l_{2} \cos{\left(\operatorname{q_{2}}{\left(t \right)} \right)} \frac{d^{2}}{d t^{2}} \operatorname{q_{2}}{\left(t \right)} - l_{3} \sin{\left(\operatorname{q_{3}}{\left(t \right)} \right)} \left(\frac{d}{d t} \operatorname{q_{3}}{\left(t \right)}\right)^{2} + l_{3} \cos{\left(\operatorname{q_{3}}{\left(t \right)} \right)} \frac{d^{2}}{d t^{2}} \operatorname{q_{3}}{\left(t \right)}\right) \cos{\left(\operatorname{q_{3}}{\left(t \right)} \right)} + l_{3} m_{3} \left(l_{1} \sin{\left(\operatorname{q_{1}}{\left(t \right)} \right)} \frac{d^{2}}{d t^{2}} \operatorname{q_{1}}{\left(t \right)} + l_{1} \cos{\left(\operatorname{q_{1}}{\left(t \right)} \right)} \left(\frac{d}{d t} \operatorname{q_{1}}{\left(t \right)}\right)^{2} + l_{2} \sin{\left(\operatorname{q_{2}}{\left(t \right)} \right)} \frac{d^{2}}{d t^{2}} \operatorname{q_{2}}{\left(t \right)} + l_{2} \cos{\left(\operatorname{q_{2}}{\left(t \right)} \right)} \left(\frac{d}{d t} \operatorname{q_{2}}{\left(t \right)}\right)^{2} + l_{3} \sin{\left(\operatorname{q_{3}}{\left(t \right)} \right)} \frac{d^{2}}{d t^{2}} \operatorname{q_{3}}{\left(t \right)} + l_{3} \cos{\left(\operatorname{q_{3}}{\left(t \right)} \right)} \left(\frac{d}{d t} \operatorname{q_{3}}{\left(t \right)}\right)^{2}\right) \sin{\left(\operatorname{q_{3}}{\left(t \right)} \right)}\end{matrix}\right]$




```python

```


```python

```

5607424328c45259586d5a5b5646502bbad6a1c8
ipynb
Jupyter Notebook
Pendula/Simple/3Pendulum/3Pendulum.ipynb
ethank5149/Classical-Mechanics
4684cc91abcf65a684237c6ec21246d5cebd232a
MIT
Pendula/Simple/3Pendulum/3Pendulum.ipynb
ethank5149/Classical-Mechanics
4684cc91abcf65a684237c6ec21246d5cebd232a
MIT
Pendula/Simple/3Pendulum/3Pendulum.ipynb
ethank5149/Classical-Mechanics
4684cc91abcf65a684237c6ec21246d5cebd232a
MIT
Qwen/Qwen-72B
1. YES
2. YES