Home / Sketching with Math and Quasi Physics / Chaos Theory カオス理論 / Physical Chaos 物理的なカオス Derivation of the equations (by AI) Here is the full, unabbreviated derivation of the equations of motion for a double pendulum using Lagrangian mechanics, written by AI (Gemini).
In physics and mathematics, the dot above a variable is Newton’s notation for the time derivative. It is a shorthand way of saying how much this value is changing with respect to time.
θ \theta θ (Theta): The Angle (Position).
θ ˙ \dot{\theta} θ ˙ (Theta-dot): The Angular Velocity (How fast the angle is changing).1 This is the a1_v and a2_v in your JavaScript code.2
θ ¨ \ddot{\theta} θ ¨ (Theta-double-dot): The Angular Acceleration (How fast the velocity is changing). This is the a1_a and a2_a that your getAccelerations function calculates.
We define the positions ( x 1 , y 1 ) (x_1, y_1) ( x 1 , y 1 ) and ( x 2 , y 2 ) (x_2, y_2) ( x 2 , y 2 ) of the two masses in terms of the angles θ 1 \theta_1 θ 1 and θ 2 \theta_2 θ 2 . We assume the y y y -axis points downwards.
x 1 = l 1 sin θ 1 x_1 = l_1 \sin \theta_1 x 1 = l 1 sin θ 1
y 1 = l 1 cos θ 1 y_1 = l_1 \cos \theta_1 y 1 = l 1 cos θ 1
x 2 = l 1 sin θ 1 + l 2 sin θ 2 x_2 = l_1 \sin \theta_1 + l_2 \sin \theta_2 x 2 = l 1 sin θ 1 + l 2 sin θ 2
y 2 = l 1 cos θ 1 + l 2 cos θ 2 y_2 = l_1 \cos \theta_1 + l_2 \cos \theta_2 y 2 = l 1 cos θ 1 + l 2 cos θ 2
2. The Lagrangian (L L L )
The Lagrangian is the difference between the Kinetic Energy (T T T ) and the Potential Energy (V V V ).
Kinetic Energy (T T T ):
Summing T = 1 2 m v 2 {\displaystyle T = \frac{1}{2}mv^2} T = 2 1 m v 2 for both masses (where v 2 = x ˙ 2 + y ˙ 2 v^2 = \dot{x}^2 + \dot{y}^2 v 2 = x ˙ 2 + y ˙ 2 ):
T = 1 2 m 1 l 1 2 θ ˙ 1 2 + 1 2 m 2 [ l 1 2 θ ˙ 1 2 + l 2 2 θ ˙ 2 2 + 2 l 1 l 2 θ ˙ 1 θ ˙ 2 cos ( θ 1 − θ 2 ) ] {\displaystyle T = \frac{1}{2} m_1 l_1^2 \dot{\theta}_1^2 + \frac{1}{2} m_2 \left[ l_1^2 \dot{\theta}_1^2 + l_2^2 \dot{\theta}_2^2 + 2 l_1 l_2 \dot{\theta}_1 \dot{\theta}_2 \cos(\theta_1 - \theta_2) \right] } T = 2 1 m 1 l 1 2 θ ˙ 1 2 + 2 1 m 2 [ l 1 2 θ ˙ 1 2 + l 2 2 θ ˙ 2 2 + 2 l 1 l 2 θ ˙ 1 θ ˙ 2 cos ( θ 1 − θ 2 ) ]
Potential Energy (V V V ):
Taking the pivot as the zero-energy reference:
V = − ( m 1 + m 2 ) g l 1 cos θ 1 − m 2 g l 2 cos θ 2 V = -(m_1 + m_2) g l_1 \cos \theta_1 - m_2 g l_2 \cos \theta_2 V = − ( m 1 + m 2 ) g l 1 cos θ 1 − m 2 g l 2 cos θ 2
Lagrangian (L = T − V L = T - V L = T − V ):
L = 1 2 ( m 1 + m 2 ) l 1 2 θ ˙ 1 2 + 1 2 m 2 l 2 2 θ ˙ 2 2 + m 2 l 1 l 2 θ ˙ 1 θ ˙ 2 cos ( θ 1 − θ 2 ) + ( m 1 + m 2 ) g l 1 cos θ 1 + m 2 g l 2 cos θ 2 {\displaystyle L = \frac{1}{2}(m_1 + m_2)l_1^2\dot{\theta}_1^2 + \frac{1}{2}m_2l_2^2\dot{\theta}_2^2 + m_2l_1l_2\dot{\theta}_1\dot{\theta}_2\cos(\theta_1-\theta_2) + (m_1+m_2)gl_1\cos\theta_1 + m_2gl_2\cos\theta_2} L = 2 1 ( m 1 + m 2 ) l 1 2 θ ˙ 1 2 + 2 1 m 2 l 2 2 θ ˙ 2 2 + m 2 l 1 l 2 θ ˙ 1 θ ˙ 2 cos ( θ 1 − θ 2 ) + ( m 1 + m 2 ) g l 1 cos θ 1 + m 2 g l 2 cos θ 2
3. Euler-Lagrange Equations
To find the equations of motion, we solve the following for each angle θ i \theta_i θ i :
d d t ( ∂ L ∂ θ ˙ i ) − ∂ L ∂ θ i = 0 {\displaystyle \frac{d}{dt} \left( \frac{\partial L}{\partial \dot{\theta}_i} \right) - \frac{\partial L}{\partial \theta_i} = 0} d t d ( ∂ θ ˙ i ∂ L ) − ∂ θ i ∂ L = 0
Performing the partial derivatives and time derivatives leads to two coupled second-order differential equations:
( m 1 + m 2 ) l 1 θ ¨ 1 + m 2 l 2 θ ¨ 2 cos ( θ 1 − θ 2 ) + m 2 l 2 θ ˙ 2 2 sin ( θ 1 − θ 2 ) + ( m 1 + m 2 ) g sin θ 1 = 0 (m_1+m_2)l_1\ddot{\theta}_1 + m_2l_2\ddot{\theta}_2\cos(\theta_1-\theta_2) + m_2l_2\dot{\theta}_2^2\sin(\theta_1-\theta_2) + (m_1+m_2)g\sin\theta_1 = 0 ( m 1 + m 2 ) l 1 θ ¨ 1 + m 2 l 2 θ ¨ 2 cos ( θ 1 − θ 2 ) + m 2 l 2 θ ˙ 2 2 sin ( θ 1 − θ 2 ) + ( m 1 + m 2 ) g sin θ 1 = 0
l 2 θ ¨ 2 + l 1 θ ¨ 1 cos ( θ 1 − θ 2 ) − l 1 θ ˙ 1 2 sin ( θ 1 − θ 2 ) + g sin θ 2 = 0 l_2\ddot{\theta}_2 + l_1\ddot{\theta}_1\cos(\theta_1-\theta_2) - l_1\dot{\theta}_1^2\sin(\theta_1-\theta_2) + g\sin\theta_2 = 0 l 2 θ ¨ 2 + l 1 θ ¨ 1 cos ( θ 1 − θ 2 ) − l 1 θ ˙ 1 2 sin ( θ 1 − θ 2 ) + g sin θ 2 = 0
By solving the above linear system for θ ¨ 1 \ddot{\theta}_1 θ ¨ 1 and θ ¨ 2 \ddot{\theta}_2 θ ¨ 2 , we obtain the formulas used in the getAccelerations function:
Acceleration of the first arm (θ ¨ 1 \ddot{\theta}_1 θ ¨ 1 ):
θ ¨ 1 = − g ( 2 m 1 + m 2 ) sin θ 1 − m 2 g sin ( θ 1 − 2 θ 2 ) − 2 sin ( θ 1 − θ 2 ) m 2 ( θ ˙ 2 2 l 2 + θ ˙ 1 2 l 1 cos ( θ 1 − θ 2 ) ) l 1 ( 2 m 1 + m 2 − m 2 cos ( 2 θ 1 − 2 θ 2 ) ) {\displaystyle \ddot{\theta}_1 = \frac{-g(2m_1+m_2)\sin\theta_1 - m_2g\sin(\theta_1-2\theta_2) - 2\sin(\theta_1-\theta_2)m_2( \dot{\theta}_2^2l_2 + \dot{\theta}_1^2l_1\cos(\theta_1-\theta_2) )}{l_1(2m_1+m_2-m_2\cos(2\theta_1-2\theta_2))}} θ ¨ 1 = l 1 ( 2 m 1 + m 2 − m 2 cos ( 2 θ 1 − 2 θ 2 )) − g ( 2 m 1 + m 2 ) sin θ 1 − m 2 g sin ( θ 1 − 2 θ 2 ) − 2 sin ( θ 1 − θ 2 ) m 2 ( θ ˙ 2 2 l 2 + θ ˙ 1 2 l 1 cos ( θ 1 − θ 2 ))
Acceleration of the second arm (θ ¨ 2 \ddot{\theta}_2 θ ¨ 2 ):
θ ¨ 2 = 2 sin ( θ 1 − θ 2 ) ( θ ˙ 1 2 l 1 ( m 1 + m 2 ) + g ( m 1 + m 2 ) cos θ 1 + θ ˙ 2 2 l 2 m 2 cos ( θ 1 − θ 2 ) ) l 2 ( 2 m 1 + m 2 − m 2 cos ( 2 θ 1 − 2 θ 2 ) ) {\displaystyle \ddot{\theta}_2 = \frac{2\sin(\theta_1-\theta_2) \left( \dot{\theta}_1^2l_1(m_1+m_2) + g(m_1+m_2)\cos\theta_1 + \dot{\theta}_2^2l_2m_2\cos(\theta_1-\theta_2) \right)}{l_2(2m_1+m_2-m_2\cos(2\theta_1-2\theta_2))} } θ ¨ 2 = l 2 ( 2 m 1 + m 2 − m 2 cos ( 2 θ 1 − 2 θ 2 )) 2 sin ( θ 1 − θ 2 ) ( θ ˙ 1 2 l 1 ( m 1 + m 2 ) + g ( m 1 + m 2 ) cos θ 1 + θ ˙ 2 2 l 2 m 2 cos ( θ 1 − θ 2 ) )