Fractal Explorer

Adjust recursion depth and watch self-similar patterns emerge from simple rules.

Loading interactive simulation...

Lesson

The theory — Fractal Explorer

A fractal dimension is what happens when you insist that "dimension" mean how detail multiplies as you zoom in, and then apply that to a shape built by repetition. The panel reports one for whichever shape is on screen, and the numbers are not whole: the Koch snowflake is 1.262, the Sierpiński triangle 1.585, the Cantor set 0.631. A shape can be more than a line and less than a plane, and the menu here contains eight of them.

0.631 Cantor ≈1 tree 1.262 Koch 1.585 Sierpiński 1.893 fern 2 dragon · Lévy · Hilbert 0 a line a plane a dust

A horizontal axis of fractal dimension from 0 to 2, with the eight shapes in the menu marked at their dimensions between a line and a plane.

  1. The Cantor set at 0.631 is the surprise: below dimension 1, more than a scatter of points and less than a line. Its total length is zero and it still has uncountably many points.
  2. Koch at 1.262 and Sierpiński at 1.585 occupy the space the word "fractal" was invented for — genuinely between a line and a plane, and neither an approximation nor a rounding.
  3. The Barnsley fern at ≈ 1.893 is close to filling the plane without ever doing it, and its value is approximate because its four maps overlap.
  4. Three constructions land on exactly 2 — the dragon, the Lévy C curve and Hilbert’s. They are not curves that wander close to filling a region; in the limit they fill it.

What each symbol means

N
how many copies of itself the rule makes at each step. Koch replaces one segment with 4; Sierpiński replaces one triangle with 3.
r
how much smaller each copy is. Koch scales by ⅓, Sierpiński by ½, the Lévy C curve by 1/√2.
D
the Hausdorff dimension the panel prints, log N / log(1/r) — the exponent that makes the copies and the scaling agree.
depth
how many times the rule has actually been applied on screen. It stops at 7, and every D above is the limit as it goes to infinity.

Where the formula comes from

  1. Start with shapes you already trust. Halve a line and it takes 2 copies to rebuild; halve a square and it takes 4; halve a cube and it takes 8. The pattern is N = (1/r)^D, where D is 1, 2 and 3 — dimension is the exponent relating copies to scaling, and nothing about that definition requires the answer to be a whole number.
  2. Solve it for D. Taking logs of N = (1/r)^D gives D = log N / log(1/r). That is the formula the panel prints, and every part of it is visible in the construction rule above it.
  3. Read a rule off the page and put it in. Koch replaces one segment with 4 of length ⅓, so N = 4 and 1/r = 3, giving log 4 / log 3 ≈ 1.262. Sierpiński gives log 3 / log 2 ≈ 1.585. Neither is an integer, and that is not an approximation — it is what the shape is.
  4. Now run the arithmetic somewhere it surprises you. The Lévy C curve replaces one segment with 2 at 1/√2, so log 2 / log √2 = 2 exactly; Hilbert replaces one with 4 at ½, giving log 4 / log 2 = 2. A dimension of exactly 2 means these are not curves that wander — in the limit they fill an area, which is why the panel calls them space-filling instead of quoting a decimal.

How to read what you see

Change the shape and watch the count row change its name: Triangles for Sierpiński, Segments for Koch, Branches for the tree, Intervals for Cantor, Points for Hilbert and the fern. That is not decoration — "how many pieces" genuinely means something different in each construction, and the panel refuses to flatten them into one word. Every count matches the formula printed beside it: at depth 4 Sierpiński shows 81 = 3⁴, Koch 768 = 3·4⁴, Cantor 16 = 2⁴, Hilbert 256 = 4⁴, and the tree 31 = 2⁵ − 1. Set the depth to 0 and then walk it up one step at a time; the count column is the rule, arithmetic made visible.

Assumes
That the copies are exact and do not overlap. D = log N / log(1/r) is a statement about strict self-similarity, which is why the panel is willing to print an exact ratio of logarithms for Koch and Sierpiński — and why it prints ≈ 1.893 for the Barnsley fern and ≈ 1 for the tree instead. The fern is built by four affine maps with different ratios that overlap, and the tree changes dimension when you change its branch angle. The tilde is doing real work.
Breaks when
Nothing on the screen is a fractal. The depth slider stops at 7, and at depth 7 the Koch curve is 3·4⁷ = 49,152 straight segments with a perfectly finite total length — an ordinary polygon whose dimension is exactly 1. Every value in the panel is a limit the drawing is heading towards and never reaches, and the same goes the other way: the space-filling curves enclose zero area at every depth you can select. The honest reading of this page is that you are watching a sequence, and the fractal is what the sequence is for.

None of these fractals comes from a complex polynomial — every one is a rule repeated 🖖

Not one of the eight shapes here is a Mandelbrot set, and none needs a complex number. Every one is built by substitution: replace a segment with a smaller arrangement of segments, then do it again, and the depth slider is literally how many times. That construction hands you the dimension directly. Koch replaces one segment with four at a third the length, so its dimension is log 4 / log 3 = 1.262 — and at the depth 4 the preset ships, its length is already (4/3)⁴ = 3.16 times the line you started with. Sierpinski gives log 3 / log 2 = 1.585. Cantor gives log 2 / log 3 = 0.631, a set with less than one dimension.

One rule, repeated, becomes everything 🖖

Every shape here grows from a single instruction the program applies to itself. A fractal-tree branch simply spawns two shorter branches, and each of those repeats the same rule — that is recursion. Nudge the depth up by one and the branch count doubles, yet the rule you wrote never changes. Each nested call piles onto the call stack, then unwinds as the picture finishes.

A dragon curve haunts Jurassic Park 🖖

The dragon curve in this explorer is the Heighway dragon, produced by folding a strip of paper repeatedly and opening every crease to a right angle. Michael Crichton put it in his 1990 novel Jurassic Park: each of the book's seven sections opens with the curve at one deeper iteration, mirroring how a tiny disturbance escalates into chaos. Chosen by mathematician Ian Malcolm, it is mathematics as a storytelling device.

Three of these eight curves have dimension exactly 2 🖖

Run the same arithmetic on the rest of the menu and something odd falls out. The dragon and the Lévy C curve each replace one segment with two at 1/√2 of the length, giving log 2 / log √2 = 2 exactly. Hilbert replaces one with four at half the length: log 4 / log 2 = 2 again. A dimension of exactly 2 means these are not really curves that wander through the plane — at infinite depth they fill it, visiting every point of a region. That is why they look solid long before the depth slider runs out, while Koch at 1.262 never does.

The fern is drawn by chance and comes out identical every time 🖖

Barnsley is the odd one out: not a substitution rule but a chaos game. Start at a point, pick one of four affine maps at random — weighted 1%, 85%, 7%, 7% — apply it, plot, repeat. Nothing about that says "fern", yet a fern is what appears. And it is the same fern on every visit, because the tool seeds its generator with a fixed 42, so the sequence of choices never varies. The deeper point is that it would not matter if it did: an iterated function system converges on its attractor regardless of which random path you take through it. The randomness is essential to the method and irrelevant to the answer.

Problem solved in full

  1. The Sierpiński triangle at depth 5 with 243 pieces 5 steps

    At depth 5 the Sierpiński triangle has 243 pieces. Derive that, then find the depth at which less than 1% of the original area survives — and what the perimeter is doing while the area vanishes.

    1. The construction is a single recurrence: every triangle becomes three. Solving it needs no more than noticing it is geometric.

    2. Each child has half the side, so a quarter of the area, and there are three of them. Multiply the two factors and the area rule appears.

    3. Evaluate both at depth 5. Just under a quarter of the area is left — 23.7% — and the boundary is already 7.59 times its original length.

    4. Dimension is defined by the exponent that keeps count × sizeD constant under the rule. Three copies at half scale forces 3 = 2D, and nothing about the drawing enters.

    5. Now solve the area rule for the depth at which 1% remains. Logarithms give 16.01, so depth 17 — and by then the triangle count has passed 129 million, which is why the tool stops well short of it.

    Answer

    Depth 17, by which point there are 129,140,163 triangles. The two quantities move in opposite directions and both do so geometrically: area falls as (3/4)ⁿ toward zero while total perimeter climbs as (3/2)ⁿ without limit. A shape whose area tends to zero and whose boundary tends to infinity is not badly behaved, it is simply not one-dimensional and not two-dimensional either — and the exponent that reconciles the two, log 3 / log 2 = 1.585, is what "dimension" has to mean once you allow shapes like this. Note it is not something measured about the picture; it falls out of the counting rule alone.

References (3)

Example problems

  • Sierpinski - Depth 6, so 3⁶ = 729 triangles with 17.8% of the original area left and a boundary 11.39 times its starting length. Dimension log 3 / log 2 = 1.585.
  • Koch snowflake - Depth 4: every segment has become four at a third the length, four times over, so the outline is (4/3)⁴ = 3.16 times the line you began with. Dimension 1.262.
  • Fractal tree - Depth 10, and the branch count doubles at every step, so this is 2¹⁰ = 1,024 tips drawn from a rule of three lines.
  • Dragon curve - Depth 12, so 2¹² = 4,096 segments. Its dimension is exactly 2, which is why it looks solid: at infinite depth it fills a region of the plane.
  • Cantor set - The only entry with a dimension below 1: log 2 / log 3 = 0.631. At depth 6 the 64 surviving intervals hold 8.8% of the original length.
  • Barnsley fern - Not a substitution rule but a chaos game: four affine maps picked at random, weighted 1%, 85%, 7% and 7%. The tool seeds its generator with 42, so the fern is identical on every visit.
  • Hilbert curve - One segment becomes four at half the length, so log 4 / log 2 = 2 exactly. At depth 5 its 1,024 cells have already covered the square.
  • Lévy C curve - Two segments at 1/√2 of the length give log 2 / log √2 = 2 - the same dimension as the dragon curve, and for the same reason.