Mandelbrot set: Difference between revisions

Content added Content deleted
(→‎Mercator zooms of the Mandelbrot set using NumPy: Formula simplified by using the logarithm for base 2 and improved the resolution of the zoomed images.)
(→‎Mercator zooms of the Mandelbrot set using NumPy: Shifting escape times towards zero before compression)
Line 7,174: Line 7,174:
T[N] = T[N] - np.log2(np.log2(abs(Z[N])) / np.log2(r))
T[N] = T[N] - np.log2(np.log2(abs(Z[N])) / np.log2(r))


T = T ** 0.5 # escape times are compressed with a concave function
T = T - T.min() # shifting escape times towards zero before compression
m = T.min() # minimum value of the transformed escape times
T = T ** 0.5 # compression of the escape times with a concave function


fig, ax = plt.subplots(figsize=(4, 3))
fig, ax = plt.subplots(figsize=(4, 3))
ax.imshow(T, cmap=plt.cm.twilight_shifted, vmin=m)
ax.imshow(T, cmap=plt.cm.twilight_shifted)
plt.savefig("Mandelbrot_set.png", dpi=100)
plt.savefig("Mandelbrot_set.png", dpi=100)


Line 7,185: Line 7,185:


fig, ax = plt.subplots(figsize=(6, 4))
fig, ax = plt.subplots(figsize=(6, 4))
ax.scatter(A, B, s=S, c=T, cmap=plt.cm.twilight_shifted, vmin=m)
ax.scatter(A, B, s=S, c=T, cmap=plt.cm.twilight_shifted, vmin=0)
plt.savefig("Mandelbrot_plot.png", dpi=100)</lang>
plt.savefig("Mandelbrot_plot.png", dpi=100)</lang>
A small change in the code above allows Mercator zooms of the Mandelbrot set (cf. David Madore: [http://www.madore.org/~david/math/mandelbrot.html ''Mandelbrot set images and videos'']). Escape time compression is used as described by David Madore.
A small change in the code above allows Mercator zooms of the Mandelbrot set (cf. David Madore: [http://www.madore.org/~david/math/mandelbrot.html ''Mandelbrot set images and videos'']). Escape time compression is used as described by David Madore.
Line 7,214: Line 7,214:
T[N] = T[N] - np.log2(np.log2(abs(Z[N])) / np.log2(r))
T[N] = T[N] - np.log2(np.log2(abs(Z[N])) / np.log2(r))


T = T ** 0.5 # escape times are compressed with a concave function
T = T - T.min() # shifting escape times towards zero before compression
m = T.min() # minimum value of the transformed escape times
T = T ** 0.5 # compression of the escape times with a concave function


fig, ax = plt.subplots(figsize=(4, 12))
fig, ax = plt.subplots(figsize=(4, 12))
ax.imshow(T, cmap=plt.cm.twilight_shifted, vmin=m)
ax.imshow(T, cmap=plt.cm.twilight_shifted)
plt.savefig("Mercator_map.png", dpi=100)
plt.savefig("Mercator_map.png", dpi=100)


Line 7,225: Line 7,225:


fig, ax = plt.subplots(2, 2, figsize=(12, 12))
fig, ax = plt.subplots(2, 2, figsize=(12, 12))
ax[0, 0].scatter(A[0:300], B[0:300], s=S[0:300], c=T[0:300], cmap=plt.cm.twilight_shifted, vmin=m)
ax[0, 0].scatter(A[0:300], B[0:300], s=S[0:300], c=T[0:300], cmap=plt.cm.twilight_shifted, vmin=0)
ax[0, 1].scatter(A[100:400], B[100:400], s=S[0:300], c=T[100:400], cmap=plt.cm.twilight_shifted, vmin=m)
ax[0, 1].scatter(A[100:400], B[100:400], s=S[0:300], c=T[100:400], cmap=plt.cm.twilight_shifted, vmin=0)
ax[1, 0].scatter(A[200:500], B[200:500], s=S[0:300], c=T[200:500], cmap=plt.cm.twilight_shifted, vmin=m)
ax[1, 0].scatter(A[200:500], B[200:500], s=S[0:300], c=T[200:500], cmap=plt.cm.twilight_shifted, vmin=0)
ax[1, 1].scatter(A[300:600], B[300:600], s=S[0:300], c=T[300:600], cmap=plt.cm.twilight_shifted, vmin=m)
ax[1, 1].scatter(A[300:600], B[300:600], s=S[0:300], c=T[300:600], cmap=plt.cm.twilight_shifted, vmin=0)
plt.savefig("Mercator_zoom.png", dpi=100)</lang>
plt.savefig("Mercator_zoom.png", dpi=100)</lang>