from matplotlib import pyplot as plt
import numpy as np
max_iter = 1024
center = -1.1195+0.2718j
extent = 0.005+0.005j
# max_iter = 256
width = 256
height = 256
# center = -0.8+0.0j
# extent = 3.0+3.0j
scale = max((extent / width).real, (extent / height).imag)
result = np.zeros((height, width), int)
for j in range(height):
for i in range(width):
c = center + (i - width // 2 + (j - height // 2)*1j) * scale
z = 0
for k in range(max_iter):
z = z**2 + c
# if (z * z.conjugate()).real > 4.0:
if abs(z) > 2.0:
break
result[j, i] = k
scale
0.01171875
i = 50
j
c = center + (i - width // 2 + (j - height // 2)*1j) * scale
c
(-1.7140625+1.48828125j)
(z * z.conjugate()).real
13.61906555814892
abs(z)
3.6904018152701097
fig, ax = plt.subplots(1, 1, figsize=(10, 10))
plot_extent = (width + 1j * height) * scale
z1 = center - plot_extent / 2
z2 = z1 + plot_extent
ax.imshow(result**(1/3), origin='lower', extent=(z1.real, z2.real, z1.imag, z2.imag))
ax.set_xlabel("$\Re(c)$")
ax.set_ylabel("$\Im(c)$");
# https://youtu.be/ZQFwzyFsElA
# https://youtu.be/9M7dTmvJxwA
# https://youtu.be/LhOSM6uCWxk
n = complex(45, 12)
n
(45+12j)
n.real
45.0
n.imag
12.0
abs(n)
46.57252408878007