For anyone interested, here's the same code in Python using the third party Numpy and Matplotlib modules. Linux or windows or Mac of course. I read that Numpy runs some orders of magnitude faster than Matlab and of course Python/Numpy requires no license fee.
In addition to interactive sessions, the code above can be run with the debugging module pdb for line by line execution and inspection:
import numpy as np import pylab import math iterations = 80 N=500 x,y = np.meshgrid(np.linspace(-1.5, 1.5, N), np.linspace(-1.5, 1.5, N)) c = -0.123 + 0.745j z = x+y*1j map = np.zeros( (N,N)) sqrt5 = math.sqrt(5) for k in range(iterations): print "iteration:",k z = z**2 + c a = np.where(np.abs(z)<sqrt5) map[a] = k pylab.imshow(map) pylab.show()
import pdb ... #run when debugging desired pdb.set_trace()