만델브로트_집합
만델브로트 집합
- m.py
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)"
만델브로트_집합.txt · 마지막으로 수정됨: 2024/03/23 02:38 저자 127.0.0.1