====== 만델브로트 집합 ====== import numpy as np def mandelbrot(z,maxiter): c = z for n in range(maxiter): if abs(z) > 2: return n z = z*z + c return maxiter def mandelbrot_set(xmin,xmax,ymin,ymax,width,height,maxiter): r1 = np.linspace(xmin, xmax, width) r2 = np.linspace(ymin, ymax, height) return (r1,r2,[mandelbrot(complex(r, i),maxiter) for r in r1 for i in r2]) if __name__ == '__main__': print(mandelbrot_set(-2.0,0.5,-1.25,1.25,1000,1000,80)) $ python -m timeit "import m; m.mandelbrot_set(-2.0,0.5,-1.25,1.25,1000,1000,80)" * https://www.ibm.com/developerworks/community/blogs/jfp/entry/How_To_Compute_Mandelbrodt_Set_Quickly?lang=en {{tag>benchmark python}}