Other sites

Mandelbrot Set, evolved

The Mandelbrot Set is perhaps the most famous fractal of all time. It's simple in its definition: iterate the complex equation zn+1 = zn2 + c (starting with z0 = 0) for various values of c, and if doesn't go to infinity then c is part of the Mandelbrot Set. The result, however, is amazingly complex. Thinking of c as defining a 2-dimensional area, the boundary of set (between where z does and does not zoom to infinity) is infinitely crenellated. And if you decorate the interior of the set with colors defined by the absolute value of z after N iterations, beautiful patterns emerge.

Because complex numbers are natural data types in the R language, it's easy to generate the Mandelbrot Set in just a few lines of code. And it's very quick, because each iteration is done over an entire grid of c values in a single statement. The code can be found in R's Wikipedia page (and reproduced after the jump). You've probably seen the Mandelbrot set before, but you may never have seen how it evolves from one iteration to the next. The R code below shows us by using the caTools package to creare an animated GIF.