# [Maxima] Optimization of Mandelbrot calculation

Fri May 1 02:50:19 CDT 2009

```Hi,

I'm not sure but maybe :
- writing procedure in Lisp is faster then Maxima
- compiling procodure makes it faster

http://www.mrob.com/pub/muency/speedimprovements.html

also look at :
http://fisica.fe.up.pt/maxima/dynamicalsystems/index.html

Some images in Maxima :
http://apps.sourceforge.net/mediawiki/maxima/index.php?title=Gallery
http://commons.wikimedia.org/wiki/File:Mandelbrot_Components.svg
http://commons.wikimedia.org/w/index.php?title=File:ComponentNewton.png
http://commons.wikimedia.org/w/index.php?title=File:Jung200.png
http://commons.wikimedia.org/w/index.php?title=File:Jung50e.png

fraktal.republika.pl

Maximilian Kreuter pisze:
> 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]]);

```