Chapter 02 · Part I · What a fractal is

Fractal dimension

A line is one-dimensional, a square two, a cube three. A coastline, it turns out, is somewhere in between, and so is the Koch snowflake's edge. This chapter shows why the length of a fractal curve is the wrong question, what the right number is, and three ways to measure it, two of which you can run yourself below.

1.2619dimension of the Koch curve, log 4 / log 3: four copies, each a third the size
1.5850dimension of the Sierpinski triangle, log 3 / log 2: three copies, each half the size
2Hausdorff dimension of the Mandelbrot set's boundary, a curve as rough as a curve can be in the plane (Shishikura, 1998)

Common mix-up: fractal dimension is not a measure of how complicated a picture looks, and it doesn't say what shape something is. The Koch curve, a single unbroken line, and Cantor dust, a cloud of separate points, have exactly the same dimension, 1.2619. Dimension measures one thing: how fast the amount of detail grows as you look more closely.

The paradox

How long is the coast of Britain?

Lewis Fry Richardson was a British physicist and meteorologist, the man who first tried to forecast the weather by solving equations by hand. Late in life he studied the statistics of wars, and wondered whether the chance of two countries fighting depended on the length of the border they shared. When he went to look up those lengths, he found that different reference books gave noticeably different figures for the same border. Nobody had made a mistake. They had measured with different-sized steps.

Richardson set out to measure the effect. He walked a pair of dividers around coastlines and land frontiers on maps, step by step, at a series of openings, and recorded the total each time. For a smooth curve the totals would have settled down to a single number. For real coastlines they never did. The smaller the step, the longer the coast, without any sign of leveling off. And the growth was regular: plotted on logarithmic axes, the measured length against the step size made a straight line.

Richardson died in 1953, and his results appeared in 1961, in an appendix to his study of war. They might have stayed obscure if Benoit Mandelbrot had not picked them up. His 1967 paper in Science, "How Long Is the Coast of Britain? Statistical Self-Similarity and Fractional Dimension," argued that the slope of Richardson's line was not a nuisance but the most important thing about the coastline: a number describing its roughness, behaving exactly like a dimension that is not a whole number.

L(r) = M × r1 − D
Richardson's law. Measure with a ruler of length r and you get length L. M is a constant that depends on the coastline's overall size. D is the dimension. When D = 1 the exponent is zero and the ruler doesn't matter: the curve has a length. When D is more than 1, halving the ruler multiplies the length by 2D − 1, every time.

Taking logarithms turns the law into a straight line, log L = log M + (1 − D) log r, which is why Richardson's plots were straight. The slope is 1 − D, so you can read the dimension straight off it. For the west coast of Britain, Richardson's measurements give a slope of about −0.25, so D ≈ 1.25. For the coast of South Africa, one of the smoothest he measured, D ≈ 1.02: nearly a plain curve.

So the honest answer to "how long is the coast of Britain?" is: it depends on your ruler, and it depends in a precise way. Ask instead how fast the length grows as the ruler shrinks, and you get a number that doesn't depend on the ruler at all. That number is the fractal dimension.

Go deeper: why a real coastline stops being fractal

Richardson's law can't hold forever in either direction. With a ruler longer than the island you get nonsense; with a ruler smaller than a grain of sand you start measuring individual pebbles and then molecules, and the coastline stops being a well-defined line at all. Long before that, the tide moves the waterline by meters twice a day.

What the law claims is that across the range of scales that maps and surveys care about, roughly from tens of meters to hundreds of kilometers, there's no characteristic size where the coast suddenly becomes smooth. That is a statement about the physics of erosion and geology, and the dimension is how you test it. Coasts formed by different processes, such as fjords cut by glaciers or long sandy beaches built by waves, tend to come out with different dimensions.

Instrument 1

A coastline ruler

This island's coast is built by a random fractal rule whose dimension you choose: every edge is replaced by four edges, with the middle two bent into a point that randomly faces in or out, seven times over. The program then does what Richardson did. It walks the coast with dividers at twelve different openings, records the length each time, plots log length against log of one over the ruler, and fits a straight line. Because the plot runs toward shorter rulers, the line climbs, and the fitted dimension is 1 plus its slope. Pick a ruler to see its walk drawn on the island, change the dimension, or roll a new coast.

Steps with this ruler–
Measured length–
Fitted dimension–
Built-in dimension–

Copies and scale

Similarity dimension

Here is a way to see why ordinary dimensions are what they are, which then works for fractals too. Take a line segment and cut it into pieces a third as long. You get 3 pieces. Take a square and cut each side into thirds: you get 9 small squares. A cube cut the same way gives 27 small cubes. Three, nine, twenty-seven: 3¹, 3², 3³. The exponent is the dimension.

In general, if a shape is made of N copies of itself, each scaled down by a factor s, then N = sD, and D is the dimension. For ordinary shapes that just restates what you already knew. The surprise is what happens when you apply it to a fractal.

N = sD so D = log N / log s
N copies, each 1/s the size of the whole. For a square, 4 copies at half size: D = log 4 / log 2 = 2. For the Koch curve, 4 copies at a third the size: D = log 4 / log 3 ≈ 1.2619. Any base of logarithm works, as long as you use the same one top and bottom.

The Koch curve is four copies of itself, each one third as long. If it were one-dimensional, four copies at a third the size would need to be three copies; if it were two-dimensional, it would need nine. It's in between, and the formula says exactly where: 1.2619. The Sierpinski triangle is three copies at half size. A one-dimensional thing would need two copies, a two-dimensional one four; the triangle sits at 1.5850, much closer to a surface than the Koch curve does. That matches the eye: the triangle looks much more like a filled shape than the snowflake's edge does.

This is the similarity dimension. It's the easiest to compute and the most intuitive, but it only works for shapes that are made of exact scaled copies of themselves, and only when the copies don't overlap too much.

ShapeCopies NScale 1/sD = log N / log sTopological dimension
Line segment21/2log 2 / log 2 = 11
Square41/2log 4 / log 2 = 22
Cube81/2log 8 / log 2 = 33
Cantor set21/3log 2 / log 3 ≈ 0.63090
Koch curve41/3log 4 / log 3 ≈ 1.26191
Sierpinski triangle31/2log 3 / log 2 ≈ 1.58501
Sierpinski carpet81/3log 8 / log 3 ≈ 1.89281
Menger sponge201/3log 20 / log 3 ≈ 2.72681
Cantor dust (plane)41/3log 4 / log 3 ≈ 1.26190
Go deeper: copies of different sizes, and the Moran equation

What if the copies are not all the same size? Suppose a shape is made of one copy at half size and one at a quarter size. There is no single s to plug in. The fix, due to P. A. P. Moran in 1946, is to ask which D makes the scaled "D-dimensional sizes" add back up to the whole:

r₁D + r₂D + … + rND = 1
The Moran equation. Each rᵢ is the scale factor of one copy. When all the copies have the same ratio r = 1/s, it collapses to N·rD = 1, which is N = sD again.

For the half-and-quarter example, write x = (1/2)D. Then (1/4)D = x², and the equation is x + x² = 1, whose positive solution is x = (√5 − 1)/2 ≈ 0.618. So D = log(1/0.618) / log 2 = log φ / log 2 ≈ 0.6942, where φ is the golden ratio. Slightly bigger than the Cantor set's 0.6309, which makes sense: one of the pieces is bigger than a third.

The answer is only trustworthy if the copies don't overlap much. The technical requirement, the "open set condition" used by John Hutchinson in 1981, says roughly that you can find a region whose shrunken copies fit inside it without overlapping. Barnsley's fern violates it: its leaflets overlap the main frond, so the Moran equation overestimates its dimension. Box counting, next, has no such restriction.

A method for anything

Counting boxes

Similarity dimension needs exact copies. A coastline, a cloud or a photograph of a fern has none. For those there is a more general method, simple enough to do with graph paper.

Lay a grid of square boxes of side s over the shape and count how many boxes contain any part of it. Call that N(s). Now halve the box size and count again. For a smooth curve, halving the boxes roughly doubles the count, because the curve passes through twice as many boxes along its length. For a filled area, halving the boxes multiplies the count by four. For a fractal, the count grows by some factor in between, the same factor at every scale, and that factor tells you the dimension.

N(s) ≈ C × (1/s)D so D ≈ log N(s) / log(1/s)
The number of occupied boxes grows like one over the box size raised to the power D. In practice you count at several box sizes, plot log N against log(1/s), and take the slope of the best straight line. That slope is the box-counting dimension.

The Sierpinski triangle shows the idea perfectly. Draw it on a grid of 1,024 by 1,024 pixels, the way Instrument 2 does. With boxes 512 pixels across you need 3 boxes. With boxes of 256 you need 9; with 128, 27. Every halving of the box multiplies the count by exactly 3, all the way down to single pixels, where there are 3¹⁰ = 59,049 of them. Three is 2 to the power 1.585, and there is the dimension again, found without knowing anything about how the triangle was built.

Real data is messier, in ways worth knowing before you trust a number.

  • The range matters most. At the smallest boxes every image is made of pixels, and pixels are not fractal. At the largest, a handful of boxes covers everything. Only the straight middle of the plot means anything, and you should report which range you fitted.
  • Grid position matters a little. Shift the grid by half a box and the counts change slightly. Careful studies average over several offsets or take the minimum count.
  • Line thickness matters. A curve drawn 3 pixels wide behaves like a filled area at box sizes below 3 pixels, and the slope there drifts toward 2.
  • A straight-looking plot is not proof. Plenty of non-fractal shapes give roughly straight plots over a factor of 10. Over a factor of 1,000, it's convincing.
Go deeper: box dimension and its relatives

Mathematicians define the box-counting dimension as a limit: D = lim log N(s) / log(1/s) as s goes to 0. The limit doesn't always exist, so there are upper and lower versions, using the limit superior and inferior. You'll also see it called the Minkowski–Bouligand dimension or capacity dimension, and the boxes can be replaced by disks, or by any reasonable family of small sets, without changing the answer.

For exactly self-similar shapes that satisfy the open set condition, the box dimension, the similarity dimension and the Hausdorff dimension all agree. They can disagree on stranger sets. The rational numbers between 0 and 1 are the standard example: they are dense, so every box along the interval contains one and the box dimension is 1; but they are countable, a list of separate points, and their Hausdorff dimension is 0. That difference is the reason mathematicians prefer the Hausdorff dimension, and the reason everyone else uses box counting: it's the one you can compute.

Instrument 2

A box-counting estimator

Pick a shape, or choose "Draw your own" and draw on the left panel with a mouse or finger. The program rasterizes the shape onto a grid of 1,024 or 729 pixels a side, then counts how many boxes are occupied at every box size from one pixel up, and fits a line to the log-log plot on the right. The left panel shades the occupied boxes at the size you pick. Narrow the fit range to see how much the answer depends on it.

Boxes occupied at this size–
Estimated dimension–
Exact dimension–
Straightness of fit (R²)–

The mathematician's version

Hausdorff dimension in plain words

Box counting and similarity both work by covering a shape with pieces of one size. The definition that mathematicians treat as the real one, introduced by Felix Hausdorff in 1919 and developed by Abram Besicovitch, allows pieces of any sizes, each as small as you like, and it starts from a question you can ask about ordinary shapes.

Ask how long a square is. Lay a curve back and forth across it, closer and closer, and the total length goes to infinity: a square has infinite length. Ask its volume, and the answer is zero: it's flat. Only one question gives a sensible, finite answer, and that's area. The dimension of the square is the power, 2, at which the measurement jumps from infinite to zero. Hausdorff's idea is to make that power a dial that can take any value, not just 1, 2 or 3.

Here is how. Cover the shape with small sets, say little disks, each of diameter at most δ. For a trial dimension d, add up each disk's diameter raised to the power d. Find the cover that makes this sum smallest, then let δ shrink to zero. For a d that's too small, the sum blows up to infinity, like measuring a square's length. For a d that's too big, it falls to zero, like measuring its volume. There is exactly one value where it switches over. That value is the Hausdorff dimension.

Hd(F) = limδ→0 inf Σ |Ui|d, dim F = the d where Hd jumps from ∞ to 0
Cover the set F with pieces Uᵢ no bigger than δ, sum their sizes to the power d, take the most economical cover, and shrink δ. Below the dimension the answer is infinite; above it, zero. At the dimension itself it can be anything, including a finite, positive "d-dimensional size" of the set.

Two features make it the mathematicians' favorite. Because each piece can be a different size, the cover can adapt to the shape, using big pieces where it's sparse and tiny ones where it's crowded; that's what makes a countable set of points come out with dimension 0, as it should. And it has clean rules: a set's dimension never exceeds the dimension of anything containing it, and the dimension of a union of countably many sets is the largest of their dimensions.

The price is that it's almost impossible to compute directly. In practice you prove that it equals the similarity dimension, or the box dimension, for the shape you care about, and compute that instead. The famous exceptions are proofs. In 1998 Mitsuhiro Shishikura proved that the boundary of the Mandelbrot set has Hausdorff dimension exactly 2: as rough as a curve in the plane can possibly be, yet (it's believed, though not proven) with zero area.

Go deeper: the Koch curve's Hausdorff dimension, in one line

Cover the Koch curve with the 4ᵏ pieces from step k of its construction, each of diameter 3⁻ᵏ (times the length of the base). The sum for trial dimension d is 4ᵏ × 3⁻ᵏᵈ = (4/3ᵈ)ᵏ. If 3ᵈ is less than 4 this grows without limit as k increases; if 3ᵈ is more than 4 it shrinks to zero. The switch is at 3ᵈ = 4, which is d = log 4 / log 3.

That shows the dimension is at most log 4 / log 3, because one particular cover gives that answer and Hausdorff measure takes the best cover. Proving it's not smaller, that no cleverer cover does better, is the hard half, and it's where the open set condition comes in. Falconer's Fractal Geometry gives the full argument.

Worked examples

A ladder of dimensions

Put the numbers in order and a picture emerges. Below 1 are dusts: scattered points with no length. Between 1 and 2 are curves and networks that wiggle more and more until they nearly fill an area. Between 2 and 3 are spongy surfaces and solids full of holes.

DimensionShapeWhat it isHow it's known
0.6309Cantor setA line with the middle third removed, foreverSimilarity: log 2 / log 3
1.02Coast of South AfricaOne of the smoothest coasts Richardson measuredRichardson's divider data, via Mandelbrot (1967)
1.25West coast of BritainThe coastline that named the paradoxRichardson's divider data, via Mandelbrot (1967)
1.2619Koch curve; Cantor dustFour copies at one third; one connected, one in piecesSimilarity: log 4 / log 3
1.5236Boundary of the Heighway dragonThe edge of the paper-folding dragon (Chapter 5)Computed exactly from its self-similar structure
1.5850Sierpinski triangleThree copies at half sizeSimilarity: log 3 / log 2
1.8928Sierpinski carpetEight copies at one thirdSimilarity: log 8 / log 3
2Boundary of the Mandelbrot setA curve as rough as a planar set can beProof: Shishikura, 1998
2.7268Menger spongeTwenty copies at one third: a cube full of tunnelsSimilarity: log 20 / log 3
Go deeper: same dimension, different texture

The Koch curve and the planar Cantor dust both have dimension log 4 / log 3, and they could hardly look more different. One is a single unbroken line; the other is infinitely many separate points. Dimension measures how fast detail accumulates as you zoom. It says nothing about whether the pieces are connected, how they are arranged, or how big the gaps are.

Mandelbrot introduced the word lacunarity, from the Latin lacuna, a gap, for that last property: how gappy or clumpy a fractal is at a given dimension. Two forests can have canopies with the same dimension and different lacunarity, one evenly speckled, one with big clearings. Researchers who classify textures in medical images or landscapes usually measure both.

Side by side

Three ways to measure, compared

MethodWorks onHowWatch out for
SimilarityExactly self-similar shapesD = log N / log s from the constructionOverlapping copies (the fern); unequal copies need Moran's equation
Divider (Richardson)CurvesSlope of log length against log ruler; D = 1 − slopeOnly for curves; self-affine curves can mislead
Box countingAnything you can draw or photographSlope of log N against log(1/s)Fit range, pixel size, line thickness, grid offset
HausdorffEvery set, in principleWhere the d-dimensional measure jumps from ∞ to 0Almost never computable directly; proved, not measured
Cheat sheet

Terms from this chapter

Coastline paradox
A coastline's measured length keeps growing as the measuring step shrinks, so it has no single length.
Richardson's law
L(r) = M·r1−D: measured length is a power of ruler length. The slope on log-log axes is 1 − D.
Similarity dimension
D = log N / log s for a shape made of N copies scaled by 1/s.
Moran equation
Σ rᵢD = 1: similarity dimension when the copies have different scale factors.
Box-counting dimension
The slope of log N(s) against log(1/s), where N(s) counts grid boxes of size s that touch the shape.
Hausdorff dimension
The power d at which the most economical cover's Σ sized switches from infinity to zero. The rigorous definition.
Topological dimension
The everyday whole-number dimension: 0 for dust, 1 for a curve, 2 for a surface.
Open set condition
The copies in a self-similar shape don't overlap too much; when it holds, the dimensions agree.
Fit range
The scales over which a power law is fitted. Always report it.
Lacunarity
How gappy a fractal is. Two sets with the same dimension can differ in it.
Where this comes from

Sources