The Iteration
The Mandelbrot set is defined by a deceptively simple rule: for each complex number c, iterate z = z² + c starting from z = 0. If the sequence remains bounded (|z| ≤ 2) after many iterations, c belongs to the set.
function mandelbrot(cx: number, cy: number, maxIter = 256) {
let zx = 0, zy = 0;
for (let i = 0; i < maxIter; i++) {
const zx2 = zx * zx, zy2 = zy * zy;
if (zx2 + zy2 > 4) return i; // escaped
zy = 2 * zx * zy + cy;
zx = zx2 - zy2 + cx;
}
return maxIter; // bounded — in the set
}Coloring Methods
Escape-time coloring assigns colors based on how many iterations it takes for a point to escape. Smooth coloring interpolates between iteration bands using the final |z| value for seamless gradients. Orbit traps measure the closest approach of the orbit to a geometric shape (circle, cross, point), revealing internal structure.
Infinite Depth
Deep-zooming into boundary regions reveals an endless hierarchy of self-similar structures — miniature copies of the set, spiral galaxies of filaments, and seahorse valleys. Each zoom level reveals new complexity, mathematically proven to continue forever.
