Advertisement
Guest User

Untitled

a guest
Feb 20th, 2020
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.89 KB | None | 0 0
  1. import cmath
  2. import matplotlib.pyplot as plt
  3.  
  4. def mandelbrot(accuracy, tries):
  5. #   c_re = -1.0284577557351740
  6. #   c_im = 0.3614638238945933j
  7. #   c = c_re + c_im
  8.   z_re_arr = []
  9.   z_im_arr = []
  10.   for x in range(800):
  11.     c = [0,0]
  12.     c[0] = (float(x)-600)/400
  13.     for y in range(800):
  14.           c[1] = ((float(y)-400)/400)
  15.           i = 0
  16.           z_re = 0
  17.           z_im = 0
  18.           while i <= tries:
  19.             z = z_re + (z_im*1j)
  20.             z_re = z**2 + c[0]
  21.             z_im = z**2 + c[1]*1j
  22.             z_re = z_re.real
  23.             z_im = z_im.imag
  24.             if z_re > 0.5 or z_re < -1.5 or z_im > 1 or z_im < -1:
  25.               break
  26.             else:
  27.               i += 1
  28.           if i >= tries:
  29.               z_re_arr.append(z_re)
  30.               z_im_arr.append(z_im)
  31.           else:
  32.             pass
  33.   plt.scatter([z_re_arr], [z_im_arr], 1)
  34. mandelbrot(100, 500)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement