What Is a Fractal? The Math Behind Infinite Complexity

A coastline that gets longer the closer you measure it. A triangle with holes punched in it forever. Here's why fractals break your intuition for length, area, and dimension, and the formula that makes sense of it.

By Petrus Sheya

July 25, 2026 · 5 min read

How long is the coastline of Britain?

Sounds like a simple question. Grab a map, grab a ruler, done. But here's the thing: measure it with a long ruler and you get one number. Measure it with a shorter ruler and you get a bigger number. Keep shrinking the ruler and the length keeps climbing, with no end in sight.

That's not a measurement error. That's a fractal.


How long is a coastline, really?

A coastline is jagged. Bays inside bays, inlets inside inlets, all the way down to individual rocks and grains of sand. A long ruler skips over all that detail, it jumps straight across a bay instead of tracing its edge. A short ruler catches more of the wiggle.

So the "length" you get depends entirely on the ruler you chose. Shrink the ruler, and you catch finer and finer detail that was always there, just skipped before.

Shrink the ruler and watch the measured length climb, the same coastline gets “longer” the more finely you measure it.

Steps taken19
Measured length686
Straight-line distance501

Drag that slider down. The measured length keeps growing. Not because the coastline changed, but because you're finally counting detail you were ignoring. A smooth circle wouldn't do this, shrink the ruler on a circle and the measured length converges to a fixed number. A coastline never settles down.

That's the first hint that a coastline isn't a normal 1-dimensional curve. It behaves like something in between a line and a surface.


Same pattern, every zoom level

Let's build something with that same "never settles down" property on purpose. Start with a triangle. Cut out the middle piece, leaving three smaller triangles in the corners. Now do the exact same thing to each of those three, forever.

Zoom into the top corner. Notice the pattern never simplifies, it's the same shape at every scale.

Magnification1.0×
Triangles in view~729

Hit play and zoom into that top corner. Notice what doesn't happen: the pattern doesn't get simpler, and it doesn't get more complicated either. It looks the same. Forever.

That's called self-similarity. Zoom into any piece of the shape and you find a smaller copy of the whole thing. This is the defining feature of a fractal: it's a shape built by repeating one simple rule at every scale, so no amount of zooming ever reaches a "smooth" or "simple" version of it.


A shape with infinite perimeter and finite area

Self-similarity gets stranger once you start measuring. Take a triangle again, but this time, on every iteration, replace the middle third of every edge with a little outward-pointing bump. Repeat forever. This is the Koch snowflake.

Push the iterations up. The perimeter keeps growing with no ceiling, the area barely moves.

Relative perimeter1.78×
Relative area1.48×

Watch the two numbers as you push nn up. The perimeter keeps growing, iteration after iteration, with no upper bound. But the area? It barely nudges. It's boxed in, always smaller than a circle drawn around the whole shape.

An infinitely long boundary, wrapped around a finite patch of space. That's not a contradiction, it's just what happens when a shape keeps adding detail at every scale instead of eventually going smooth. Each iteration multiplies the perimeter by 43\frac{4}{3}, and (43)n\left(\frac{4}{3}\right)^n \to \infty as nn \to \infty. The area, meanwhile, converges, because each new bump adds a shrinking sliver that gets tinier faster than the perimeter grows.

This is exactly the coastline paradox, just built out of a clean rule instead of a messy coastline.


So what is a fractal's dimension?

We need a better idea of "dimension" than "1 for a line, 2 for a square." Here's the intuition: if you take a line segment and shrink it by a factor of ss, you need 1s\frac{1}{s} copies to rebuild the original. Shrink a square by ss and you need 1s2\frac{1}{s^2} copies. Shrink a cube and you need 1s3\frac{1}{s^3}.

Notice the pattern? The exponent is the dimension. So we can flip the formula around and use it to solve for dimension when we don't already know it:

D=logNlog(1/s)D = \frac{\log N}{\log(1/s)}

where NN is how many self-similar copies you get, and ss is how much each one is shrunk. Try it yourself:

Change how many pieces each side splits into. Watch the dimension land somewhere between a line and a flat square.

D = log(8) / log(3)1.893
Copies kept, N8
Scale factor, s0.333
Dimension, D1.893

At k=2k = 2, removing one quarter and keeping the rest gives D1.58D \approx 1.58. At k=3k = 3, the classic Sierpinski carpet, removing the center square gives D1.89D \approx 1.89. Neither is 1, neither is 2. The shape is too crowded for a line and too full of holes for a plane, and the dimension formula measures exactly that in-between-ness.

Run the same formula on the Koch snowflake's edge: each side splits into N=4N = 4 pieces at scale s=13s = \frac{1}{3}, giving D=log4log31.26D = \frac{\log 4}{\log 3} \approx 1.26. That's why the coastline ruler experiment behaved the way it did. A real coastline has a fractal dimension a little above 1, somewhere around 1.2 to 1.3 depending on the coast, which is precisely why shrinking the ruler never lets the measured length settle down.


The short version

A fractal is a shape built by repeating the same simple rule at every scale, so zooming in never reveals a smooth, simplified version, just the same pattern again. That self-similarity breaks our usual intuition for length and area: perimeters can grow without bound while area stays finite, and a "how long is this" question can depend entirely on how finely you measure. To make sense of shapes like this, we stop asking "is it a line or a surface" and start asking "how many self-similar copies, at what scale," which gives us a dimension that can land anywhere between whole numbers, not just on them.

All four visualizations above are interactive React components rendering plain SVG in your browser, no external libraries, no canvas. Drag the sliders, hit play, and watch the numbers move with the shapes.