![[mandelbrot.jpg]] You've probably seen this shape a million times. This is the Mandelbrot set, named after Benoit Mandelbrot, who introduced fractals to the world with his famous 1967 paper, *How Long Is the Coast of Britain?* While the surface area of this shape is bounded, its edge is infinitely long, much like that of the coast of Britain. No matter how much you zoom in onto the edge, you're going to find more and more roughness, subshapes of subshapes that have a length of their own. It never ends. The Mandelbrot set is described by the following equation. $ \begin{align} f_c(z)_{n+1}=z_{n}^2+c \end{align} $ You define if a complex number $c$ belongs to the set by apply the formula over and over to it. If the number is stable, meaning that it's bounded and doesn't reach out towards infinity as we apply the calculation times and times again, the point belongs to the set. Otherwise, it does not. The interesting part happens near the edge of the set (the shape in the middle). As we consider even the tiniest variations of numbers that live next to each other, we get widely different results. This is why the set is related to chaos: Any change, even of the smallest account, can lead to a drastically different outcome. Numbers that live near the edge of the set, no matter how close, do or do not belong to the set, resulting in that infinite edge which in the above illustration appears as the brightest part. Those bright point do not belong to the set, they define its contour. Before diving into drawing the set ourselves, we first need to make sure we understand what complex numbers are. Many implementations out there skip that entirely and apply premade recipes without getting into the math, which I'd like to address here as it will give you a firm understanding of what the set is and what the formula does. The math is really not that complex... apart for the fact it deals with complex numbers. ## Complex numbers Complex numbers are composed of a real part and an imaginary part. You can think of them as a point on a $2d$ plane with an $x$-axis and a $y$-axis. The real part would be the $x$-coordinates of that point, and the imaginary part would be the $y$-coordinates. The imaginary part comes from $\sqrt{-1}$. It's not possible for a square root to yield $-1$ when dealing with numbers on the real number line. A number that has a negative square root in it is said to have an imaginary part, otherwise this is a real number living on a one dimensional line with its $y$-coordinates being $0$. The imaginary part is denoted $i$, which is equal to $\sqrt{-1}$. Consider for instance $\sqrt{-76}$. You can rewrite it $\sqrt{-1 \cdot 76}$, and then $i\sqrt{76}$. The coordinates of our number on the complex plane are $(0, \sqrt{76})$.