Monday, October 08, 2007

Mandelbrot Set in Excel

As part of my "anything you can do, I can do in Excel" crusade, I made a spreadsheet to compute the Mandelbrot set (2.5 MB file). This takes roughly 5 seconds per iteration on a single-core Pentium 4 at 2.6 GHz. Excel also seems to consume 128 MB of memory to compute the 400 x 350 x 2 sheets of cells (compare to 28 MB just to run Excel). The slowness and memory overhead (probably related) of this operation in Excel points to some serious design flaws in the underlying spreadsheet calculation system. Considering the spreadsheet file is around 2.5 MB, I can't see why the entire thing would require more than say 5 MB (one to store the current iteration and one to store the next in order to preserve atomicity). Since Excel's iteration is blocking assignments in reading order, the actual iteration could require no more memory than the entire 2.5 MB sheet if atomicity of the iteration operation is not a concern. Since this spreadsheet is embarrassingly parallel and requires vastly more floating point resources than can fit on an FPGA, it makes for a good benchmark of a resource sharing compiler (aka a serializing compiler).

Time for pictures. These are produced by Excel's conditional cell coloring. The images link to bigger PNG versions.


After 1 iteration (minx = -2, maxy = 1, dx = .01, dy = .01)




After 2 iterations

Several iterations later, it starts to resemble a Mandelbrot set.

Several more iterations and some cells start to diverge.



Everyone's favorite fractal: the Mandelbrot Set!


Zooming in on a particular section and iterating a bunch.

4 comments:

Tyler Mulligan said...

Awesome, I love it. Have you ever seen that video of the guy that creates an anime pic out of html tables?

mattman206 said...

Wow, this looks really neat. Any chance you could post an Office 2003 version of the spreadsheet for those of us without Office 2007?

Anonymous said...

The download link for the file is unavailable. Would you be totally awesome and email it to me tacoexpressunite@gmail.com

Unknown said...

I've downloaded the spreadsheet but it's mostly 0's on the first page and the output page is red. Do I have to enter variables?