eureka
experiment 029 · nonlinear dynamics

The Spring Pendulum

A point mass suspended from a pivot by an elastic spring. It has two degrees of freedom: it can swing like a pendulum and bounce like a spring. The nonlinear coupling between these modes allows energy to slosh back and forth, producing complex, chaotic trajectories from a remarkably simple setup. Drag the bob to stretch the spring and change the angle, then release it to watch it go.

The system

The generalised coordinates are the radial distance $r$ from the pivot and the angle $\theta$ from the downward vertical. The Lagrangian $L = T - V$ is given by:

$$ \begin{aligned} T = \frac{1}{2} m \left( \dot{r}^2 + r^2 \dot{\theta}^2 \right) \\ V = -m g r \cos\theta + \frac{1}{2} k (r - L_0)^2 \end{aligned} $$

Applying the Euler–Lagrange equations $\frac{d}{dt} \frac{\partial L}{\partial \dot{q}} - \frac{\partial L}{\partial q} = 0$ yields the equations of motion for $r$ and $\theta$:

$$ \begin{aligned} \ddot{r} = r \dot{\theta}^2 + g \cos\theta - \frac{k}{m} (r - L_0) \\ \ddot{\theta} = -\frac{g}{r} \sin\theta - \frac{2 \dot{r} \dot{\theta}}{r} \end{aligned} $$

Numerical note

The system is integrated using 4th-order Runge–Kutta (RK4) with a fixed step size. Because of the non-linear coupling (the Coriolis term $-\frac{2 \dot{r} \dot{\theta}}{r}$ and the centrifugal term $r \dot{\theta}^2$), the motion can be highly chaotic. The energy of the system is tracked to monitor integrator stability. If you observe energy drift (visible in the $|\Delta E|$ readout), try reducing the integration speed to take smaller steps per frame.

← back to workshop