The Mandelbrot Set: Infinite Complexity from Simple Rules

How does iterating z → z² + c produce infinite complexity? Explore the Mandelbrot set's computation, smooth colouring algorithms, the sibling Julia sets, and the deep connection between fractals and natural structures from coastlines to lungs.

In 1980, Benoît Mandelbrot printed the first recognisable image of the set bearing his name on an IBM computer at Yorktown Heights, New York. The printout was crude by today's standards — a blocky ASCII-style rendering on paper — but the self-similar, infinitely complex boundary was unmistakable. It had emerged from a two-line equation. Nearly five decades later, the Mandelbrot set remains one of the most visually and mathematically astonishing objects in all of mathematics: a structure of infinite richness hiding inside a formula simple enough to type on a single line of code.

The Algorithm: Complex Iteration

A complex number c is a member of the Mandelbrot set if, and only if, the sequence defined by the recurrence z₀ = 0, zₙ₊₁ = zₙ² + c does not diverge to infinity when iterated forever. Computationally, we apply an escape condition: if the modulus |z| ever exceeds 2, the sequence is guaranteed to diverge to infinity, and the point escapes. We stop iterating and record how many steps it took.

function mandelbrot(cx, cy, maxIter) { let zx = 0, zy = 0; for (let i = 0; i < maxIter; i++) { const zx2 = zx * zx - zy * zy + cx; zy = 2 * zx * zy + cy; zx = zx2; if (zx * zx + zy * zy > 4) return i; } return maxIter; }

Points that never escape — those returning maxIter — are in the Mandelbrot set and are coloured black. Points that escape are coloured by how quickly they escape: fast escapers get one colour, slow escapers get another. The iteration limit is typically set between 100 and 1000; higher limits reveal finer detail near the boundary but require more computation. At the boundary itself — the infinitely thin edge between convergence and divergence — the iteration count can be arbitrarily high.

Why the escape radius is 2: It can be proved mathematically that if |z| ever exceeds 2, the orbit z₀, z₁, z₂, … will diverge to infinity. Using a larger escape radius (say, 100) enables the smooth colouring algorithm described below, at negligible computational cost.

Smooth Colouring and the Escape Radius Algorithm

Naively colouring pixels by their integer iteration count produces ugly concentric bands — visible "rings" around the set. The banding arises because iteration count is a discrete quantity, changing by whole numbers, while the true divergence speed varies continuously. The solution is the continuous (or smooth) escape time algorithm.

When a point escapes at iteration i with final value z, the smooth escape time is computed as:

mu = i - log(log(|z|) / log(2)) / log(2)

This correction term removes the integer staircase, producing a smooth real number that increases continuously as points move away from the set boundary. Mapping mu to a colour palette — typically cycling through hue in HSL space, or through a carefully designed gradient — produces the smooth, flame-like colour bands that have made Mandelbrot visualisations iconic.

The zoom depth achievable in software is staggering. The standard double-precision floating point numbers used in most implementations can reach zoom levels of around 10¹⁵ before precision runs out and the image dissolves into a pixellated artefact. At that depth, structures appear that eerily echo the original top-level set: miniature Mandelbrot copies floating within filaments, surrounded by their own baroque filigree of spirals and bulbs. Arbitrary-precision arithmetic libraries push zoom depths to 10^1000 and beyond, revealing structure at scales that have no physical meaning — the set is not a physical object, just pure mathematics.

Julia Sets: Siblings of the Mandelbrot

The Mandelbrot set is intimately related to a family of fractals called Julia sets, named after the French mathematician Gaston Julia who studied complex iteration in 1918 — decades before anyone could visualise his work on a computer. To compute a Julia set, you reverse the roles: fix c to a specific complex number, and vary the starting point z₀ across the complex plane. For each starting point, ask the same question: does the orbit diverge?

The relationship between the two types of sets is one of the most beautiful theorems in complex dynamics:

The Mandelbrot set is therefore literally a map of Julia set connectivity. Every point on the boundary of the Mandelbrot set corresponds to a Julia set undergoing a topological phase transition from connected to disconnected. Zooming into the Mandelbrot boundary and finding a miniature Mandelbrot copy is equivalent to finding a region where local Julia sets closely resemble the whole.

The Hausdorff dimension of the Mandelbrot set's boundary was proved to be exactly 2 by Mitsuhiro Shishikura in 1998 — meaning the boundary is so infinitely complex that it fills space as thoroughly as a two-dimensional surface, despite being a curve. This is fractal dimension in its most extreme mathematical form.

Natural fractals appear wherever iterative growth processes operate without a fixed scale: coastlines measured at finer and finer resolutions grow longer indefinitely (Richardson's paradox), trees branch at statistically self-similar angles, snowflake arms grow as dendritic fractals, the bronchi of human lungs bifurcate through 23 generations, and river deltas viewed from satellite look identical at 10km and 100km scales. All have fractal dimensions between 1 and 2 — more complex than a line, less space-filling than a plane. The Mandelbrot set unites all of them as examples of the same underlying mathematical phenomenon: infinite complexity from a finite rule iterated without limit.