Mechanics Mathematics

This page explains the mathematical model used by every mechanism in the simulator. Each system is described by generalized coordinates, its kinetic energy \(T\), its potential energy \(V\), and the Lagrangian \(L=T-V\).

1. The common method

A generalized coordinate \(q_i\) describes one independent way the system can move. Its velocity is \(\dot q_i=dq_i/dt\). The Euler-Lagrange equation for every coordinate is

\[ \frac{d}{dt}\left(\frac{\partial L}{\partial \dot q_i}\right) -\frac{\partial L}{\partial q_i}=0,\qquad L=T-V. \]

The symbolic engine differentiates \(L\), collects the coefficients of the accelerations \(\ddot q_i\), and produces a linear system

\[ A(q,\dot q,t)\,\ddot q=b(q,\dot q,t). \]

The solver evaluates \(A\) and \(b\) at the current state, solves for the accelerations, and advances the state with fourth-order Runge-Kutta integration.

2. Pendulums

Simple pendulum

With \(\mathbf r=(l\sin\theta,-l\cos\theta)\):

\[ T=\frac12ml^2\dot\theta^2,\qquad V=-mgl\cos\theta, \] \[ ml^2\ddot\theta+mgl\sin\theta=0,\qquad \ddot\theta=-\frac gl\sin\theta. \]

Double pendulum

The two angles are measured from the downward vertical. The bob positions are

\[ \mathbf r_1=(l_1\sin\theta_1,-l_1\cos\theta_1), \] \[ \mathbf r_2=\mathbf r_1+ (l_2\sin\theta_2,-l_2\cos\theta_2). \]
\[ T=\frac12(m_1+m_2)l_1^2\dot\theta_1^2+ \frac12m_2l_2^2\dot\theta_2^2+ m_2l_1l_2\dot\theta_1\dot\theta_2 \cos(\theta_1-\theta_2), \] \[ V=-(m_1+m_2)gl_1\cos\theta_1-m_2gl_2\cos\theta_2. \]

The equations are coupled because the kinetic energy contains both velocities. The solver solves the resulting \(2\times2\) system at every time step.

Spherical pendulum

The polar angle \(\theta\) and azimuth \(\phi\) locate the bob on a sphere of radius \(l\):

\[ T=\frac12ml^2\left(\dot\theta^2+ \sin^2\theta\,\dot\phi^2\right),\qquad V=-mgl\cos\theta. \]

Since \(\phi\) does not appear in \(L\), it is cyclic. Its conjugate momentum is conserved:

\[ p_\phi=\frac{\partial L}{\partial\dot\phi} =ml^2\sin^2\theta\,\dot\phi. \]

Bead on a rotating hoop

A hoop rotates about its vertical diameter with prescribed angular speed \(\Omega\). For bead angle \(\theta\), the kinetic energy is

\[ T=\frac12mR^2\left(\dot\theta^2+ \Omega^2\sin^2\theta\right),\qquad V=-mgR\cos\theta. \]

The \(\Omega^2\sin^2\theta\) term is the rotational kinetic energy caused by the hoop itself, and changes the equilibria.

Kapitza pendulum

The pivot height is prescribed as \(y_p=a\cos(\Omega t)\). The bob position is

\[ x=l\sin\theta,\qquad y=a\cos(\Omega t)-l\cos\theta. \]
\[ T=\frac12m\left[ l^2\cos^2\theta\,\dot\theta^2+ \left(-a\Omega\sin(\Omega t)+l\sin\theta\,\dot\theta\right)^2 \right], \] \[ V=mg\left[a\cos(\Omega t)-l\cos\theta\right]. \]

\(L\) depends explicitly on time, so mechanical energy is not conserved. At sufficiently rapid vibration, the time-averaged dynamics can stabilize the normally unstable inverted position.

3. Springs and coupled oscillators

Elastic pendulum

Using radial extension \(r\) and angle \(\theta\), the bob is \(\mathbf r=(r\sin\theta,-r\cos\theta)\). Therefore

\[ T=\frac12m\left(\dot r^2+r^2\dot\theta^2\right), \qquad V=-mgr\cos\theta+\frac12k(r-l)^2. \]

Coupled spring-mass chain \((x_1,x_2,x_3)\)

Three masses move horizontally, with identical springs attached to both walls and between neighboring masses. Displacements are measured from equilibrium:

\[ T=\frac12m_1\dot x_1^2+\frac12m_2\dot x_2^2+ \frac12m_3\dot x_3^2, \] \[ V=\frac12k\left[x_1^2+(x_2-x_1)^2+ (x_3-x_2)^2+x_3^2\right]. \]

The equations are

\[ m_1\ddot x_1+k(2x_1-x_2)=0, \] \[ m_2\ddot x_2+k(2x_2-x_1-x_3)=0, \] \[ m_3\ddot x_3+k(2x_3-x_2)=0. \]

4. Rolling and constrained systems

Disk on a slope

The slope direction is \(\hat p=(2,-1)/\sqrt5\), and the disk center is \(\mathbf c=r\hat n+x\hat p\). Rolling without slipping gives \(\omega=\dot x/r\), so

\[ T=\frac12\left(m+\frac Ir^2\right)\dot x^2,\qquad V=mg\frac{2r-x}{\sqrt5}, \] \[ \ddot x=\frac{mg}{\sqrt5(m+I/r^2)}. \]

Cart and pendulum

For cart displacement \(x\) and pendulum angle \(\theta\), the coupled energies are

\[ T=\frac12(M+m)\dot x^2-ml\cos\theta\,\dot x\dot\theta+ \frac12ml^2\dot\theta^2, \] \[ V=mg\left(\frac12-l\cos\theta\right)+\frac12kx^2. \]

Swinging Atwood machine

With hanging coordinate \(r\) and swing angle \(\theta\):

\[ T=\frac12(M+m)\dot r^2+\frac12mr^2\dot\theta^2, \qquad V=Mgr-mgr\cos\theta, \] \[ (M+m)\ddot r-mr\dot\theta^2+ g(M-m\cos\theta)=0, \] \[ mr^2\ddot\theta+2mr\dot r\dot\theta+ mgr\sin\theta=0. \]

Rolling disk pendulum

The rolling disk pendulum has coordinates \(x,\theta_1,\theta_2\). Its kinetic energy is the sum of translational and rotational energies of the ring, inner disk, and pendulum masses:

\[ T=\frac12M|\dot{\mathbf c}_M|^2+\frac12I_M\omega_M^2+ \frac12m_r|\dot{\mathbf c}_r|^2+\frac12I_r\omega_r^2+ \frac12m_p\left(|\dot{\mathbf c}_{p+}|^2+ |\dot{\mathbf c}_{p-}|^2\right). \]

Each spring contributes \(V_s=\frac12k(|\mathbf b-\mathbf a|-l_0)^2\), and gravity contributes \(mgy\). The simulator differentiates this complete expression symbolically rather than displaying its very long expanded equations.

5. Rotational systems

Symmetric spinning top

The top uses Euler angles \(\theta,\phi,\psi\). Here \(\theta\) is nutation, \(\phi\) is precession, and \(\psi\) is spin. With transverse inertia \(I_1\) and axial inertia \(I_3\):

\[ T=\frac12I_1\left(\dot\theta^2+ \sin^2\theta\,\dot\phi^2\right) +\frac12I_3\left(\dot\psi+\dot\phi\cos\theta\right)^2, \] \[ V=mgl\cos\theta. \]

Both \(\phi\) and \(\psi\) are absent from \(L\), so their momenta are conserved:

\[ p_\psi=I_3(\dot\psi+\dot\phi\cos\theta), \] \[ p_\phi=I_1\sin^2\theta\,\dot\phi+ I_3\cos\theta(\dot\psi+\dot\phi\cos\theta). \]

6. Numerical integration and conservation

The simulation advances time in small substeps. For state \(z=(q,\dot q)\), it evaluates

\[ \dot z=f(z,t) \]

with classical fourth-order Runge-Kutta:

\[ z_{n+1}=z_n+\frac16(k_1+2k_2+2k_3+k_4), \] \[ k_1=hf(z_n,t_n),\quad k_2=hf(z_n+k_1/2,t_n+h/2), \] \[ k_3=hf(z_n+k_2/2,t_n+h/2),\quad k_4=hf(z_n+k_3,t_n+h). \]

For time-independent systems, total energy \(E=T+V\) should remain nearly constant; small changes come from numerical integration. Cyclic coordinates provide additional conserved momenta, while the explicitly time-dependent Kapitza pendulum does not conserve energy.

← Back to Mechanics