Overview: Deterministic Chaos & Multi-Link Pendulum Physics
The Multi-Pendulum Physics Visualizer explores one of the most iconic phenomena in classical and non-linear mechanics: deterministic chaos. While a single simple harmonic pendulum ($N = 1$) yields completely predictable, periodic motion governed by linear differential equations at small displacement angles ($\sin\theta \approx \theta$), adding links to form a compound double ($N = 2$), triple ($N = 3$), or general $N$-link chain introduces intense spatial non-linearity and dynamic symmetry breaking.
In a multi-link pendulum system, each additional segment acts as a forced, nonlinearly coupled oscillator. The potential energy stored in elevated masses continuously converts into kinetic energy distributed across all angular degrees of freedom ($\theta_1, \theta_2, \dots, \theta_N$). Microscopic perturbations in the initial conditions—measured in fractions of a millimeter or micro-radians—grow exponentially over time. This sensitivity to initial conditions is quantified by positive maximal Lyapunov Exponents ($\lambda > 0$), a hallmark metric of chaotic attractors and phase space turbulence.
Despite the completely deterministic mathematical formulation of the underlying equations of motion, long-term trajectory prediction becomes impossible without infinite floating-point numerical precision. This visualizer allows researchers, educators, and visual artists to observe real-time phase space exploration, trace spirographic orbit dynamics, adjust simulation speed multipliers, and investigate kinetic energy transfer across connected mechanical links.
Technical Details: Matrix Lagrangian & Time-Scaled RK4 Engine
The physics solver behind this laboratory utilizes a generalized matrix formulation of the Euler-Lagrange equations combined with a high-precision Fourth-Order Runge-Kutta (RK4) integration algorithm with sub-step time scaling.
For an $N$-link planar pendulum with rigid links of lengths $L_j$, point masses $m_j$, and angles relative to the downward vertical $\theta_j$, the global position of the $k$-th mass is given by:
$$x_k = \sum_{j=1}^k L_j \sin\theta_j, \quad y_k = -\sum_{j=1}^k L_j \cos\theta_j$$
Taking time derivatives yields the kinetic energy $T$ and potential energy $V$ of the system:
$$T = \frac{1}{2} \sum_{k=1}^N m_k (\dot{x}_k^2 + \dot{y}_k^2), \quad V = g \sum_{k=1}^N m_k y_k$$
Formulating the Lagrangian $L = T - V$ and applying the Euler-Lagrange operator $\frac{d}{dt}\left(\frac{\partial L}{\partial \dot{\theta}_j}\right) - \frac{\partial L}{\partial \theta_j} = -\gamma \dot{\theta}_j$ yields a coupled system of $N$ non-linear second-order differential equations expressible in compact matrix notation:
$$\mathbf{M}(\mathbf{\Theta}) \ddot{\mathbf{\Theta}} = \mathbf{C}(\mathbf{\Theta}, \dot{\mathbf{\Theta}}) + \mathbf{G}(\mathbf{\Theta}) - \mathbf{D} \dot{\mathbf{\Theta}}$$
Where $\mathbf{M}(\mathbf{\Theta})$ is the $N \times N$ symmetric positive-definite inertia matrix with elements:
$$M_{jk} = \left(\sum_{i=\max(j,k)}^N m_i\right) L_j L_k \cos(\theta_j - \theta_k)$$
$\mathbf{C}_j$ represents centrifugal and Coriolis force terms, $\mathbf{G}_j$ represents gravitational vector forces:
$$C_j = -\sum_{k=1}^N \left(\sum_{i=\max(j,k)}^N m_i\right) L_j L_k \sin(\theta_j - \theta_k) \dot{\theta}_k^2, \quad G_j = -\left(\sum_{i=j}^N m_i\right) g L_j \sin\theta_j$$
To control motion speed, time scaling factor $\alpha = \text{speedMultiplier}$ calculates effective frame time step $\Delta t_{\text{eff}} = \alpha \cdot \Delta t$. The solver divides this into $S$ sub-steps ($\delta t = \Delta t_{\text{eff}} / S$). For each sub-step, LU decomposition solves $\ddot{\mathbf{\Theta}} = \mathbf{M}^{-1} (\mathbf{C} + \mathbf{G} - \mathbf{D}\dot{\mathbf{\Theta}})$, advancing state vector $(\mathbf{\Theta}, \dot{\mathbf{\Theta}})$ via 4th-order Runge-Kutta evaluation stages ($k_1, k_2, k_3, k_4$).