Optimization of Mandelbrot calculation



Hi,

Maxima can handle complex number operations so :



mandel(reMin, reMax, imMin, imMax, resolution, iterations):=block(

     pixels:[[0,0]],

     for x:reMin step resolution thru reMax do (
         for y:imMin step resolution thru imMax do (
	    c:x+y*%i,
             z:0,

             for i:1 step 1 thru iterations while cabs(z) < 2 do
                 z:z*z+c,
				


             if cabs(z) < 2 then pixels:append(pixels,[[x,y]])

         )
     ),

     return(pixels)
)$

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