Barnsley Fern
Curl, plant and follow a fern drawn by random dots and four rules.
How to play
- Drag a frond sideways to curl the whole fern: you are changing two of its 28 numbers.
- Tap a frond to follow the chaos game: a glowing dot jumps by one of the four rules each time.
- Tap the soil near the fern to plant a fiddlehead and watch it unfurl.
- Open Lab for the mutant ferns and the stem-curl slider.
Challenges
- Tap the soil to plant a fiddlehead and watch it unfurl
- Drag a frond’s tip until the whole fern curls the other way
- Tap a frond and follow the dot until it has used all four rules
Try this
- Tap a frond and follow the glowing dot. Each jump uses one of the four rules, picked at random, and the stem rule turns up only about once in a hundred jumps.
- Drag a frond sideways. Changing two of the 28 numbers bends the whole fern, right down to the tiniest leaflets.
- Try the mutant ferns in the Lab. Small changes to the numbers give ferns that look like quite different species.
Fun facts
- Michael Barnsley described the fern in his 1988 book Fractals Everywhere.
- Just four rules, 28 numbers in all including the probabilities, produce the whole fern.
- The rule that builds the main body of the fern is used 85% of the time; the one that draws the stem is used only 1% of the time.
- The shape that appears does not depend on the random order of the jumps, only on the four rules themselves.
A fern made of four rules and a roll of the dice
The Barnsley fern is drawn with an iterated function system: a handful of simple rules that each move a point to a new place. Each rule is an affine map, a combination of shrinking, rotating, shearing and shifting. Barnsley’s fern uses four of them.
The chaos game
Start with a point anywhere. Pick one of the four rules at random, apply it to move the point, and put a dot there. Repeat, thousands of times. At first the dots look scattered, but very quickly a fern appears, and it is always the same fern, however the random choices fall. This is called the chaos game. Tap a frond to follow the jumping dot one rule at a time.
Why it works
Each of the four rules shrinks things. One squashes the plane onto a short line that becomes the stem. One shrinks the whole fern slightly, tilts it and moves it up, which makes the fern a copy of itself minus its bottom pair of leaflets. The other two shrink and turn the whole fern into the lowest leaflet on each side, one of them flipping it over as well. Because the fern is made of smaller copies of itself, the four rules together map the fern exactly onto itself. Mathematicians call such a shape the attractor of the system: wherever the point starts, repeated jumps pull it onto the fern, and once there it can never leave.
Self-similarity
Look closely at a leaflet and you will see that it is shaped like the whole frond, and its own lobes are shaped like it again. Real ferns are like this too, down to a few levels. The probabilities of the rules do not change the shape; they only decide how quickly each region fills with dots, which is why the main rule is chosen most often.
Unfurling fiddleheads
Real ferns unroll their young fronds from tight coils called fiddleheads, a habit botanists call circinate vernation. Here every frond you plant starts curled and unrolls as you watch: the 2D fern is bent along a curve whose coil loosens from the base towards the tip.
For the curious
Each rule maps (x, y) to (ax + by + e, cx + dy + f). Barnsley’s numbers are: stem (0, 0, 0, 0.16, 0, 0) with probability 0.01; main body (0.85, 0.04, −0.04, 0.85, 0, 1.6) with probability 0.85; left leaflet (0.2, −0.26, 0.23, 0.22, 0, 1.6) and right leaflet (−0.15, 0.28, 0.26, 0.24, 0, 0.44), each with probability 0.07. Dragging a frond sideways (or the stem-curl slider) changes b and c of the main rule together, which slightly rotates every copy.
Questions people ask
What is the Barnsley fern?
It is a fractal shaped like a fern, made by repeatedly applying one of four simple rules, chosen at random, to a point and plotting where it lands. Michael Barnsley described it in 1988.
What is the chaos game?
It is a way of drawing a fractal: start with a point, repeatedly apply a randomly chosen rule from a small set, and plot every point you visit. The dots settle onto a definite shape, the attractor of the rules.
Why does a random process make the same fern every time?
Because each rule shrinks distances, the point is pulled onto the one shape that the rules map onto itself. The random choices only decide which part of that shape the point visits next, not the shape itself.