The definition of the Mandelbrot set, together with its basic properties, suggests a simple algorithm for drawing a picture of the Mandelbrot set. The region of the complex plane under consideration is subdivided into a certain number of pixels. To color any such pixel, let c be the midpoint of that pixel. The critical value c under P
c
, is iterated checking at each step whether the orbit point has a modulus larger than 2.
If this is the case, we know that the midpoint does not belong to the Mandelbrot set, and the pixel is colored. Either it is colored white to get the simple mathematical image or it is colored according to the number of iterations used to get the well-known colorful images. Otherwise, iterating is continued for a certain number of steps that is large but fixed, after which this parameter can probably be placed in the Mandelbrot set, or at least very close to it, and color the pixel black.
In pseudocode, this algorithm would look as follows:
For each pixel on the screen do:
{
x0 = x co-ordinate of pixel
y0 = y co-ordinate of pixel
x = 0
y = 0
iteration = 0
max_iteration = 1000
while ( x*x + y*y = (2*2) AND iteration max_iteration )
{
xtemp = x*x - y*y + x0
y = 2*x*y + y0
x = xtemp
iteration = iteration + 1
}
if ( iteration == max_iteration )
then
color = black
else
color = iteration
plot(x0,y0,color)
}
http://www.kwsi.com/ynhti2009/image06.html