# The Mandelbrot Set

The entire Mandelbrot fractal is contained in the simple formula:

Z = Z² + C

Where C is the x,y point being tested, expressed as a complex number x + yi. The formula is iterated starting with Z = 0, and each time setting the new Z value to Z^{2} + C. The Mandelbrot set is defined as all points C for which Z remains finite when iterated forever.

Because it's impossible to iterate forever, we stop after a maximum number of iterations and stop early if Z gets too big. If the magnitude of Z becomes greater than 2, then it will only grow with more iterations, so we can be sure that C is not in the set.

The image above was generated using 28 iterations. In my color scheme, the blue gradient represents areas where Z grew too big before all 28 iterations had completed. These areas are outside the set, but Z grows more slowly when you are near the set, so the number of iterations produces a nice glow effect. The white areas have finished all 28 iterations, and are *probably* inside the set, but doing more iterations will reveal some white areas that aren't in the set.

It takes more iterations (more computational effort) to draw a clear image as you get closer to the boundary of the Mandelbrot set. Interestingly, the detail of the fractal also increases. Because complex number multiplication rotates the coordinates of the number, each Mandelbrot iteration increases the "swirlyness" of the fractal.

For example, look at the fractal boundary when using 28 iterations:

(Click to Open in the Mandelbrot Viewer)

Now watch as the number of iterations is increased from 28 to 128:

Now zoom into the area on the left, and increase to 2048 iterations. Look at these "octopus" patterns! They're much more complex than anything you can find using only 28 iterations.

(Click to Open in the Mandelbrot Viewer)

As you can see, the patterns become more and more artistic, swirly, and beautiful as you increase the number of iterations!

My favorite is 128 iterations because it's small enough that my viewer runs smoothly on most GPUs, but it's high enough to show a lot of detail, like these snowflakes:

(Click to Open in the Mandelbrot Viewer)

If you zoom in far enough, everything will become pixelated, but that is not the end of the fractal! The pixel blocks are merely the end of your computer's number precision. It takes more digits to go deeper into the fractal, which becomes too slow to compute in real time. The Mandelbrot fractal is like the digits of pi. It goes on forever, but gets harder to compute the further you go.