Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import cmath
- import matplotlib.pyplot as plt
- def mandelbrot(accuracy, tries):
- # c_re = -1.0284577557351740
- # c_im = 0.3614638238945933j
- # c = c_re + c_im
- z_re_arr = []
- z_im_arr = []
- for x in range(800):
- c = [0,0]
- c[0] = (float(x)-600)/400
- for y in range(800):
- c[1] = ((float(y)-400)/400)
- i = 0
- z_re = 0
- z_im = 0
- while i <= tries:
- z = z_re + (z_im*1j)
- z_re = z**2 + c[0]
- z_im = z**2 + c[1]*1j
- z_re = z_re.real
- z_im = z_im.imag
- if z_re > 0.5 or z_re < -1.5 or z_im > 1 or z_im < -1:
- break
- else:
- i += 1
- if i >= tries:
- z_re_arr.append(z_re)
- z_im_arr.append(z_im)
- else:
- pass
- plt.scatter([z_re_arr], [z_im_arr], 1)
- mandelbrot(100, 500)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement