def mandel(dx, dy):
v, c = zeros((512, 512), 'uint8'), zeros((512, 512), 'complex')
c[:].real = linspace(dy[0], dy[0] + dy[1], c.shape[0])[:, None]
c[:].imag = linspace(dx[0], dx[0] + dx[1], c.shape[1])[None, :]
z = c.copy()
for i in range(128):
z = z * z + c
v += (abs(z) >= 4) * (v == 0) * i
imshow(v)
%time mandel((.663,.007), (-.191,.007))
Wall time: 1.4 s
%time mandel((-0.07, 0.14), (-1.5, 0.14))
Wall time: 1.31 s