Take a complex number c, start at zero and repeat: square, add c. The values of c for which this never runs off to infinity form the Mandelbrot set. The rule fits on one line, yet wherever you zoom into the boundary, new spirals, tendrils and tiny copies of the whole appear.
How it works
Each pixel is a point c. The shader iterates until |z| passes 10,000 (well above the classic 2) or the budget runs out: 220 steps for the overview, thousands deep down. The colour comes from the smooth count ν, the step number plus a fraction for how far the orbit overshot. Bands count from the frame’s fastest-escaping point, so every depth looks equally rich.
The derivative z′ gives the distance estimate d, which reveals filaments thinner than a pixel and drives “Relief” and “Glow”. Orbit traps record the orbit’s closest approach to a point, line, cross or circle.
GPU float32 holds about seven digits, so near a thousandfold zoom pixels merge. The fix is perturbation: the CPU computes one reference orbit Zₙ from the frame centre in double precision, and each pixel tracks only its small offset δₙ, where seven digits suffice. If a pixel’s orbit passes closer to zero than its offset, it is rebased onto the reference. So the Mandelbrot set, tricorn, multibrots and Julia sets reach 10⁻¹²: were the set as big as the Earth, the frame would be thinner than a hair. The burning ship and Newton’s method are computed directly.
A bit of history
In 1918 Gaston Julia, who had lost his nose in the war, won the Paris Academy’s Grand Prix for a memoir on iterating rational functions; Pierre Fatou built the same theory in parallel. The first crude image of the set appeared in 1978, in a paper on Kleinian groups by Robert Brooks and Peter Matelski. In 1980 Benoit Mandelbrot studied it on IBM computers, and in 1982 Adrien Douady and John Hubbard proved it connected and named it after him. K. I. Martin published the perturbation trick in 2013.
What to tweak
- “Place” “Seahorse valley”, “Colouring” “stripes”, “Relief” near 0.7: the curls look embossed.
- “Place” “Dendrite”, then “Formula” “Julia”: the Mandelbrot set’s twigs near i repeat the Julia set’s twigs for c = i, as Tan Lei proved.
- “Place” “Abyss 10⁻¹⁰” with “Zoom” 100: the depth limit, a trillion times below the overview.
- “Newton: zⁿ − 1” with “Power” 5: all five root colours meet at every boundary point; “c: Re” and “c: Im” alter the step and swell the boundaries.
- “Inside” set to “background” makes the set transparent: put “Fractal noise” underneath for mist inside, or lay a “Mosaic” effect on top.