2026-03-31
fractal
Recursion. A return to complexity.
base function: z = z² + c | smooth color: μ = n + 1 − log₂(log₂(|z|))
Mandelbrot set iterated until escape or depth limit. Zooming into a spiral on the boundary of the Mandelbrot set. Feel free to click to zoom in elsewhere.
Resets on-entering and on-exiting full-screen to provide optimal user experience (in my opinion).
Buttons explained:
+/-changes zoom speed.R/rchanges resolution.dreturns to default zoom.
The Mandelbrot set
The Mandelbrot set is the set of all complex numbers c for which the sequence z₀ = 0, zₙ₊₁ = zₙ² + c stays bounded — that is, |z| never exceeds 2. Points outside escape to infinity; how fast they escape determines the color. Points inside never escape and are drawn in the background color.
The boundary between the two is infinitely detailed. Zoom in anywhere and new structure appears at every scale — the same spirals, filaments, and miniature copies of the whole set, forever. This self-similarity at all magnifications is the defining property of a fractal. Benoît Mandelbrot studied and popularized it in the 1970s–80s, lending the set its name.
Complex numbers
A complex number is a number of the form a + bi, where a and b are real and i = √(−1). Descartes coined "imaginary" as a dismissal, but the label stuck long after complex numbers proved indispensable. They extend the real number line into a plane: the complex plane, with a real axis and an imaginary axis.
In the Mandelbrot iteration, c = a + bi is a point in this plane. Squaring z = (a + bi) gives a² − b² + 2abi, which is why the inner loop reduces to two real recurrences — the ones in the canvas above.
Complex numbers in cryptography
Elliptic curve cryptography (ECC) draws directly on complex analysis. Elliptic curves over ℂ are isomorphic to complex tori — surfaces formed by identifying opposite edges of a parallelogram in the complex plane. The algebraic structure of this geometry underlies the elliptic curve discrete logarithm problem, which is what makes ECC hard to break.
Post-quantum cryptography uses polynomial rings such as ℤ[x]/(xⁿ + 1) — the backbone of CRYSTALS-Kyber and CRYSTALS-Dilithium, the NIST-standardized algorithms. Multiplication in these rings is accelerated by the Number Theoretic Transform (NTT), the finite-field analogue of the Fast Fourier Transform. The FFT itself operates over complex roots of unity; the NTT substitutes a prime modulus for the same reason: to make cyclic convolution efficient.
Complex numbers in AI
Rotary Position Embeddings (RoPE) — used in LLaMA, Mistral, GPT-NeoX, and most modern open-weight transformers — encode token positions by rotating query and key vectors in the complex plane. Each consecutive dimension pair is treated as a complex number and multiplied by e^(iθ), a rotation by angle θ. This gives attention a natural sense of relative distance between tokens without learned position vectors.
Complex-valued neural networks generalize standard networks by allowing complex weights and activations, so a single neuron carries both magnitude and phase. They show up in radar, MRI reconstruction, and audio processing, where the data is inherently complex — a microphone signal's Fourier transform yields amplitude and phase, and discarding phase loses information.
The Fast Fourier Transform, defined over complex exponentials, appears throughout deep learning: in spectral graph neural networks, frequency-domain convolutions, and audio models like Whisper and EnCodec, which operate on spectrograms rather than raw waveforms. FNet replaces the attention mechanism in a transformer entirely with Fourier transforms and still achieves 92% of BERT's accuracy at a fraction of the compute.