Optimization of Mandelbrot calculation



Hi,

Im using Maxima at my school and I like to use it teaching complex 
numbers and chaos theory. Therefore I like to show how to calculate and 
display the Mandelbrot-Set.

I already got it working so far (you can look at it below). The only 
problem i have is that the execution gets very slow (and sometimes takes 
forever), when I choose a lower value for the parameter "resolution" 
(e.g. 0.01 instead of 0.02).

Is there anything I could do to optimize this, or any setting i could 
change to run this faster?

BTW... Im using wxMaxima on Windows.

Any suggestions welcome;)

Cheers

Maxx




mandel(reMin, reMax, imMin, imMax, resolution, iterations):=block(
    [reZ, imZ, absZ, i, pixels, reTemp],
   
    pixels:[[0,0]],

    for x:reMin step resolution thru reMax do [
        for y:imMin step resolution thru imMax do [
           
            reZ:0,
            imZ:0,
            absZ:0,

            for i:1 step 1 thru iterations while absZ < 4 do [
                reTemp:reZ^2 - imZ^2 + x,
                imZ:2*reZ*imZ + y,
                reZ:reTemp,
                absZ:reZ^2+imZ^2 
            ],   

            if absZ < 4 then pixels:append(pixels,[[x,y]])

        ]
    ],
       
    return(pixels)
)$

plot2d([discrete, mandel(-2,0.5,-1,1, 0.02, 16)],[style, [points,0.2,1,1]]);