The Mandelbrot set is a subset of the complex numbers which meet the following recursive rule: for all complex numbers \(\mathbb{C}\), \(z \in \mathbb{C}\) is included in the Mandelbrot set if the series \[\begin{aligned} z_{n+1} &= z_n^2 + z \\ z_1 &= z \end{aligned}\] does not diverge. The set’s boundary produces a fractal figure with a perimeter of infinite length, and zooming in on any boundary point will show a repeating pattern.

It’s known that all points in the set have a magnitude less than 2, as points with magnitude greater than 2 will diverge into infinity. This means that in a practical implementation which uses a loop to find the \(z_n\) can break as soon as \(|z_n| > 2\) (or without using square roots, \(|z_n|^2 = a^2 + b^2 > 4\), for better performance). Colorization can also be done according to what lowest value \(n\) it takes for \(|z_n| > 2\).

This recursive rule, however, is not the only rule that produces such an intricate shape. With a slight modification to the original rule: \[\begin{aligned} z_{n+1} &= z_n^2 + c \\ z_1 &= z \end{aligned}\] where \(c\) is any complex number, we now have a family of similar shapes, called the Julia sets.

There is also a 3D extension of the Mandelbrot set, referred to as a Mandelbulb. The shape is defined using the same rule, however, since there is no three-dimensional extension of the complex numbers, it is instead defined using White and Nylander’s \(n\)th Power formula for the \(n\)th power of a vector \(v \in \mathbb{R}^3\) with \(v = \langle x,y,z \rangle\) where \(x,y,z \in \mathbb{R}\): \[\begin{aligned} v^n = r^n\langle \sin({n\theta)}\cos{(n\phi)}, \sin{(n\theta)}\sin{(n\phi)}, \sin{(n\phi)}\cos{(n\theta)}\rangle \end{aligned}\] where \[\begin{aligned} r &= \sqrt{x^2 + y^2 + z^2} \\ \phi &= \arctan{\frac{y}{x}} \\ \theta &= \arctan{\frac{\sqrt{x^2+y^2}}{z}} \end{aligned}\]
