[Numpy-discussion] Numpy-discussion Digest, Vol 33, Issue 59

Juanjo Gomez Navarro juanjo.gomeznavarro at gmail.com
Wed Jun 10 04:41:34 EDT 2009

Thanks a lot, now I have a quite fast program to compute Fractals :D.
Nevertheless, I want to comment some more doubts.

The speed at which some points tend to infinite is huge. Some points, after
10 steps, reach a NaN. This is not problem in my Mac Book, but in the PC the
speed is really poor when some infinities are reached (in the mac, the
program takes 3 seconds to run, meanwhile in the PC it takes more than 1
minute). In order to solve this, I have added a line to set to 0 the points
who have reached 2.0 (so they are already out of the Mandelbrot set):
for n in range(1,ITERATIONS):
  print "Iteration %d" % n
  z *= z
  z += c
  fractal[(fractal == 1) & (abs(z) > 2.0)] = float(n) / ITERATIONS

# This is the new line to avoid series in some points to reach infinite,
which causes problems in my PC
  z[abs(z) > 2.0] = 0
This solves the problem for PC, but delays the calculation...

On the other hand, the number of calculations that *really need* to be done
(of points who have not yet been excluded from the Mandelbrot set) decreases
rapidly. In the beginning, there are, in a given example, 250000 points, but
in the final steps there are only 60000. Nevertheless, I'm calculating *
needlessly* the 250000 points all the time, when only 10% of calculations
should need to be done! It is a waste of time.

Is there any way to save time in these useless calculations? The idea should
be to perform the update of z only if certain conditions are met, in this
case that abs(z)<2.


2009/6/9 <numpy-discussion-request at scipy.org>

> ttp://mentat.za.net/numpy/intro/intro.html<http://mentat.za.net/numpy/intro/intro.html>
> We never used it, but I still like the pretty pictures :-)
> Cheers
> St?fan

Juan José Gómez Navarro

Edificio CIOyN, Campus de Espinardo, 30100
Departamento de Física
Universidad de Murcia
Tfno. (+34) 968 398552

Email: juanjo.gomeznavarro at gmail.com
Web: http://ciclon.inf.um.es/Inicio.html
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20090610/ff99356e/attachment.html>

More information about the NumPy-Discussion mailing list