Fractals

Mandelbrot and Julia

Every point of the plane starts an orbit z → z² + c; the colour tells how fast it runs away. Zooms to 10⁻¹².

  • GPU shader
  • looping animation
Open in the editor →

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.

zₙ₊₁ = zₙ² + c, z₀ = 0 (Julia: z₀ is the point, c is fixed) ν = n + 1 − log₂ log₂|zₙ| d ≈ |zₙ|·ln|zₙ| / (2|zₙ′|) zₙ = Zₙ + δₙ: δₙ₊₁ = 2Zₙδₙ + δₙ² + δc

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.

Parameters

Formula
Mandelbrot · Julia · Burning ship · Tricorn · Multibrot zⁿ + c · Newton: zⁿ − 1 · Newton: z³ − 2z + 2
Power
For the multibrot and Newton's zⁿ − 1
Place
Famous spots of the Mandelbrot set; in Julia mode, the c of that spot Whole set · Seahorse valley · Elephant valley · Spiral · Double spiral · Minibrot · Forest · Snowflakes · Starfish · Tendrils · Depth 10⁻⁸ · Abyss 10⁻¹⁰ · Douady rabbit · Dendrite · San Marco · Siegel disk · Airplane · Galaxy
Centre X
Offset in frame heights of the chosen place
Centre Y
Zoom
Mandelbrot, tricorn and multibrot go to 10⁻¹² (perturbation theory); the rest as far as float precision allows
Rotation
c: Re
Added to the Julia set's c; for Newton, the step relaxation
c: Im
Colouring
smooth · stripes · distance · trap: point · trap: line · trap: cross · trap: circle
Band density
Relief
Lighting from the distance estimate to the boundary
Glow
Colour fades away from the set, with a bright rim at the boundary
Inside
background · trap · dark