Magnetic pendulum

A magnetic pendulum is a pendulum with an iron bob, swinging above a few magnets. It is a desk toy, and one of the clearest pictures of chaos: a few simple laws, and an outcome that depends on the start with impossible precision.

The fractal map of a magnetic pendulum: three colored basins around three magnets, folding into fine bands, with the pendulum's looping trail
The fractal map of a magnetic pendulum: three colored basins around three magnets, folding into fine bands, with the pendulum's looping trail

The setup

An iron ball hangs on a long string. Below it, on a table, sit two or more magnets. Let the ball go and it swings toward one magnet, overshoots, is caught by another, and loops between them until friction has taken its energy and it settles over one magnet.

The forces

Three things act on the ball. Gravity pulls it back toward the point straight under the pivot, as for any pendulum. Each magnet pulls it toward itself, most strongly when the ball passes right above it. Air and friction slow it down. The simulation uses this standard model: a pull back to the middle, a drag that grows with speed, and a magnetic pull that weakens with distance.

Chaos

The motion follows fixed laws: start the ball twice from exactly the same spot and it does exactly the same thing. But start it a hair's breadth away and, after a few loops, the two paths have nothing in common. This sensitive dependence on the starting conditions is what chaos means. It is also called the butterfly effect.

Basins of attraction

Each magnet is an attractor: a state the ball ends in. The set of starting points that end at a given magnet is its basin of attraction. Color each basin and you get the map. Close to each magnet its basin is a calm patch. Further out, the basins wind around each other in thinner and thinner bands.

A fractal border

If you could zoom into the border between two colors, it would never become a simple line. New bands keep appearing at every scale. Look closely at a boundary between two colors and you will usually find the third color there too. Mathematicians call basins with this property Wada basins.

Time as shading

The darker parts of the map are starting points from which the ball wanders longest before it settles. They lie along the borders, where the ball keeps hesitating between magnets. The bright patches near the magnets are quick, direct falls.

Try it in PictorX

Open the magnetic pendulum and the ball is already swinging over its map. Click or drag on the picture to let it go from any point, and drag the magnets to move them. Change Magnets, Friction, Height, Magnet strength, and Gravity, and the map is recalculated in the background. Set Map to 100% for the fractal alone, then save a PNG.

Frequently asked questions

What is a basin of attraction?

All the starting points from which a system ends up in the same final state. In the magnetic pendulum each magnet has one: the starting points from which the ball comes to rest over that magnet.

Why is the magnetic pendulum unpredictable if it follows exact laws?

Because tiny differences in the start grow very quickly. To predict which magnet wins from a start near a border, you would need to know that start with impossible precision.

Can I build a magnetic pendulum?

Yes. Hang a steel ball on a thread a little above a table, put two or three magnets under it, and let it go. Desk versions are sold as chaos pendulums.

Why does lower friction give a finer map?

With less friction the ball swings longer and passes the magnets more often before it settles. Every extra pass splits the starting points further, so the bands become thinner.

Ready to try it?

Open PictorX in your browser — no install, no credit card required to start.

Try the magnetic pendulum