• API
• FAQ
• Tools
• Archive
SHARE
TWEET

# Untitled

a guest Aug 20th, 2019 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. import numpy as np
2. import matplotlib.pyplot as plt
3. from tqdm import tqdm
4.
5. N = 1000
6. inital_z = 0
7.
8. epsilon = 0.01
9. center_position = [-0.7, 0.46]
10.
11. def f(z, C):
12.     return z*z + C
13.
14. def convergence_judgment(C):
15.     z = inital_z
16.     i = 0
17.     while i < 100:
18.         z = f(z, C)
19.         if abs(z) > 2:
20.             return i
21.         i += 1
22.     return i
23.
24. def show(grid):
25.     plt.figure(figsize=(15,15))
26.     plt.axis("off")
27.     plt.tick_params(labelbottom=False, labelleft=False, labelright=False, labeltop=False)
28.     plt.imshow(grid, vmin=0, vmax=100, cmap="Blues_r")
29.     plt.savefig("save/img_x{}_y{}_e{}.png".format(center_position[0], center_position[1], epsilon))
30.     plt.show()
31.
32. def main():
33.     grid = np.empty((N, N), dtype=np.uint8)
34.     points_x = np.linspace(center_position[0]-epsilon, center_position[0]+epsilon, N)
35.     points_y = np.linspace(center_position[1]-epsilon, center_position[1]+epsilon, N)
36.
37.     for n, ReC in tqdm(enumerate(points_x)):
38.         for m, ImC in enumerate(points_y):
39.             C = ReC + ImC*1J
40.             grid[m, n] = convergence_judgment(C)
41.
42.     show(grid)
43.
44. if __name__ == "__main__":
45.     main()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.

Top