Loosely based on a C language program created at uchicago.edu.
Mandelbrot sets are images of self-similar repeating structures (i.e. fractals).
To explain this code it will be necessary to introduce a few extra concepts. The first are complex numbers:
Complex numbers are special values are built from familiar real numbers, and special imaginary numbers. Thus, the operations on complex numbers allow you to perform mathematical operations on pairs of numbers. We don't expect you to understand them deeply, we just want you to grasp two points:
If you want, you can think of the calculation in pixel as just a magic box.
The next bit of magic is the "bmp" module that we have provided. It allows you to make a bitmapped image from a two-dimensional array of values. As you become more advanced in the art of programming you should eventually be able to understand how it works. For now, just use it.
What we really want you to understand from this program is the way it uses parallel programming. Rows of the image are considered as tasks. A single master process hands out tasks to the worker processes, and as the workers finish a task they come back and request another.
This way of doing things keeps all the workers busy all the time, even when the difficulty of the tasks is variable.
Possibly a simpler calculation could have been used to illustrate this style of programming, but this one makes a really cool picture. :)