Magnetic Pendulum ChaosBeta

Fractal chaos map of where a pendulum over three magnets lands

This tool is a beta version still being stabilized. Please let us know if a result looks off.

Loading the simulation engine (WebAssembly)…

Tap the map to release the pendulum from that spot

Gravity pulls the pendulum bob back toward the center, each magnet on the floor pulls it toward itself, and air drag slowly drains its energy, so it always comes to rest over one magnet. Every pixel of the map is colored by the magnet the pendulum ends on when released at rest from that point; darker pixels took longer to settle. Near the boundaries the tiniest change flips the outcome: this is chaos, and zooming in reveals ever finer structure. Tap the map to see the actual trajectory from that start, drag to pan, and use the wheel or two fingers to zoom.

About Magnetic Pendulum Chaos

Every pixel on the map is one experiment. The pendulum tip is released at rest from that spot, integrated with RK4 in 0.02-second steps for up to 120 seconds, and the pixel is painted the colour of the magnet it comes to rest over. The longer it took to settle, the darker the pixel; anything that needed 30 seconds or more gets the darkest shade.

The equation for the tip's horizontal position p is p'' = −k·p − b·p' + Σ (mᵢ − p) / (|mᵢ − p|² + d²)^{3/2}. Here k is the restoring pull of gravity, b is friction, and d is the height of the tip above the plane of the magnets, which sit evenly spaced on a circle of radius 1. With three magnets, number 1 (red) is at the top, number 2 (green) at lower left and number 3 (blue) at lower right.

Experiment 1: one pixel to the side

With the defaults (friction 0.2, gravity 0.5, height 0.25, three magnets), release the pendulum straight below the centre at twice the magnet radius, (0, −2). It swings past the two nearby lower magnets and settles over the farthest one, magnet 1 at the top, after 23.6 s. Move the start just 0.01 to the right, to (0.01, −2), and it ends on magnet 3 after 37.6 s. In the default view 0.01 is a pixel or two.

Tap the map to draw the real trajectory from any point. Inside a broad patch of one colour you can nudge the start around and nothing changes. Where colours are interleaved in thin stripes, moving by a single pixel can change the destination. The set of points where the answer flips is what this map is really showing.

Experiment 2: less friction, messier borders

Take 1,001 starting points along the horizontal line y = −1.2 from x = −2 to 2 and count how often two neighbours land on different magnets. At friction 0.4 there were 10 switches; at 0.2 (the default), 36; at 0.1, 424; at 0.05, 672. With less friction the pendulum spends longer bouncing between magnets, and every extra pass gives small differences another chance to grow. At 0.05 the border has smeared into a wide band where the outcome is effectively unknowable.

At friction 0.05, 8 of the 1,001 points had still not settled after 120 s. Those are painted in the darkest shade of whichever magnet was nearest at the end. Some of the dark blotches you see at very low friction are points that simply ran out of time.

Experiment 3: number of magnets and gravity

Along the same line, changing only the number of magnets gave 6 border crossings with two magnets, 36 with three, 132 with four and 504 with six. Two magnets split the plane almost in half with a simple border; each extra magnet adds another place the pendulum can visit and makes the paths more tangled.

Raising gravity (the restoring force) from 0.2 to 1.5 increased the count on that line from 24 to 194. A stronger pull toward the centre sends the pendulum back across the ring of magnets more often and more quickly.

Why the borders are fractal

The pendulum can end up in only three places, the rest points over the magnets. Each is an attractor, and the set of starting points that leads to it is its basin of attraction. A point exactly on the border between two basins goes to neither; it follows an unstable path. Start near the border and the pendulum shadows that unstable path for a while before peeling off, and the longer it lingers the more a tiny difference is amplified. Zoom into a border and you find finer stripes, and finer stripes inside those.

McDonald, Grebogi, Ott and Yorke (1985) showed that near a fractal basin boundary, if you know the starting point to within ε, the chance of predicting the wrong final state shrinks only like ε^α. When α is less than 1, measuring ten times more precisely cuts your error rate by less than a factor of ten. The lesson of this map is that you do not need never-ending chaos like the Lorenz attractor to lose predictability: a pendulum that always stops still leaves you unable to say where.

What this model simplifies

  • The tip is treated as moving on a flat plane with a linear restoring force −k·p, a small-swing approximation. A real pendulum tip moves on a sphere, and the difference grows the farther out you release it.
  • The magnetic pull is an inverse-square point attraction softened by the height d. Real magnets are dipoles whose force falls off faster than the cube of distance.
  • Friction is a single linear drag proportional to velocity.
  • “Settled” means within 0.05 of a magnet and moving slower than 0.05. Above a height of about 0.37 the resting point sits more than 0.05 from the magnet (about 0.07 away at height 0.4, about 0.14 at 0.5), so the pendulum also counts as settled once both its speed and its acceleration drop below 0.05, that is, once it has come to rest at an equilibrium; it is then assigned to the nearest magnet. Near a height of 0.6 the magnets pull so weakly that some points come to rest near the centre of the circle. Their colour is just whichever magnet happened to be slightly closer when they stopped, and means little.
  • The exact centre (0, 0) is in theory a balance point, but floating-point rounding picks a side and the calculation ends on magnet 2 after about 65 s.

Worked examples

0.01 apart, different magnets

Input
Friction 0.2, gravity 0.5, height 0.25, 3 magnets; starts (0, −2) and (0.01, −2)
Output
(0, −2) → magnet 1 (top) in 23.6 s; (0.01, −2) → magnet 3 (lower right) in 37.6 s

Both starts sit on a striped border, not inside a solid patch of colour.

Friction and border complexity

Input
1,001 points on y = −1.2, x from −2 to 2
Output
Border crossings: friction 0.4 → 10, 0.2 → 36, 0.1 → 424, 0.05 → 672

Each halving of friction multiplies the border structure.

How to use it

  1. Changing friction, gravity, height or magnet count recomputes the map. Skim with the Fast resolution, then refine with Sharp.
  2. Tap the map to see the trajectory, the magnet it lands on and how long it took.
  3. Drag a mixed-colour border to the centre and zoom in to find finer stripes.

Frequently asked questions

Why doesn't the pendulum go to the nearest magnet?

It starts at rest and is accelerated toward the centre by the restoring force, so it passes the magnets with speed and often overshoots the one it started near. Only releases very close to a magnet drop straight onto it.

At large heights the pendulum doesn't stop right over a magnet. Is it broken?

No. The higher the bob, the more gravity's pull toward the centre wins over the magnet, so the resting point shifts inward (about 0.07 at height 0.4). The simulation then treats coming to rest at that point as settling and assigns the nearest magnet. Near a height of 0.6 some points settle close to the centre instead (see the simplifications above).

Does a real magnetic pendulum toy do this?

The sensitivity and tangled borders show up in real toys. The exact map will differ, though, because real magnets and a real pendulum's spherical motion are not what this model uses.

Does zooming in reveal new stripes forever?

Mathematically, yes. Here, with 0.02-second steps and a 120-second limit, very deep zooms end up showing the numerical error rather than the true boundary.

Related guides

Sources

Last reviewed:

Privacy and how data is handled