Magnetic Pendulum
A damped pendulum swings above three magnets arranged in an equilateral triangle. Given enough damping it always settles onto one — but which one depends with infinite sensitivity on where it started. The boundary between the three basins of attraction is a fractal: zoom in anywhere and the same three-way tangle reappears. Click anywhere on the map to watch a live trajectory unspool to its attractor.
The equations
Work in the horizontal plane (x, y). The pendulum pivot is at the origin; the bob is displaced by (x, y) from rest. Three magnets sit at the vertices of an equilateral triangle of circumradius 1. Because the magnets lie below the pendulum's equilibrium plane by a fixed height z₀, the effective distance from the bob to magnet i is
The equations of motion are Newton's second law with three contributions: a linear restoring term from gravity (pendulum approximation), a viscous damping term, and the magnetic inverse-square-law attractions:
These are integrated with 4th-order Runge–Kutta. The simulation terminates when kinetic energy drops below a threshold; the settled position is then used to decide which magnet "won" and to colour the initial pixel accordingly. Brightness encodes convergence speed — brighter pixels settled faster.
Why fractal?
Near a three-way boundary any small perturbation to the starting point can flip the outcome between all three magnets. Zoom in on any segment of that boundary and the same tangle reappears — between two adjacent same-coloured regions there is always a sliver of the third. This self-similarity is the hallmark of fractal basin boundaries and the reason no finite map can ever fully resolve them. The phenomenon is a concrete example of the Wada property: every boundary point is simultaneously on the boundary of all three basins.
Controls
Damping γ — higher damping collapses the trajectory faster and produces cleaner
boundaries. Near zero the pendulum oscillates for a very long time and the computation slows
significantly.
Pendulum height z₀ — controls how close the bob can get to the magnets. Very small
values produce enormous forces and deeply complicated fractal boundaries; larger values soften the
map toward simple three-way Voronoi cells.
Restoring ω² — the pendulum's gravity term. Zero means no restoring force; the
outcome is then purely a race between the magnets. Increasing it biases the bob toward the origin.
Try this
Set pendulum height to 0.15 and damping to 0.05, then click High
resolution and recompute. The boundaries become extraordinarily intricate — dense spirals of colour
wind around every magnet position. Any pixel you click near a boundary will trace a trajectory
that wanders unpredictably before eventually committing to one attractor.