Mandelbrot set: Difference between revisions
Content deleted Content added
→Normalized Iteration Count, Distance Estimation and Mercator Maps: The first three examples merged into one program. |
→Normalized Iteration Count, Distance Estimation and Mercator Maps: More Mercator maps and shorter filenames |
||
Line 7,230: | Line 7,230: | ||
plt.imshow(T ** 0.1, cmap=plt.cm.twilight_shifted) |
plt.imshow(T ** 0.1, cmap=plt.cm.twilight_shifted) |
||
plt.savefig(" |
plt.savefig("Mandelbrot_set_1.png", dpi=250) |
||
N = abs(Z) > r |
N = abs(Z) > r # normalized iteration count |
||
T[N] = T[N] - np.log2(np.log(abs(Z[N])) / np.log(r)) |
T[N] = T[N] - np.log2(np.log(abs(Z[N])) / np.log(r)) |
||
plt.imshow(T ** 0.1, cmap=plt.cm.twilight_shifted) |
plt.imshow(T ** 0.1, cmap=plt.cm.twilight_shifted) |
||
plt.savefig(" |
plt.savefig("Mandelbrot_set_2.png", dpi=250) |
||
N = abs(Z) > 2 |
N = abs(Z) > 2 # exterior distance estimation |
||
D[N] = 0.5 * np.log(abs(Z[N])) * abs(Z[N]) / abs(dZ[N]) |
D[N] = 0.5 * np.log(abs(Z[N])) * abs(Z[N]) / abs(dZ[N]) |
||
plt.imshow(D ** 0.1, cmap=plt.cm.twilight_shifted) |
plt.imshow(D ** 0.1, cmap=plt.cm.twilight_shifted) |
||
plt.savefig(" |
plt.savefig("Mandelbrot_set_3.png", dpi=250) |
||
X, Y = C.real, C.imag |
X, Y = C.real, C.imag |
||
S = 150 * 2 / d # scaling depends on |
S = 150 * 2 / d # scaling depends on figsize |
||
fig, ax = plt.subplots(figsize=(8, 6)) |
fig, ax = plt.subplots(figsize=(8, 6)) |
||
ax.scatter(X, Y, s=S**2, c=D**0.1, cmap=plt.cm.twilight_shifted) |
ax.scatter(X, Y, s=S**2, c=D**0.1, cmap=plt.cm.twilight_shifted) |
||
plt.savefig(" |
plt.savefig("Mandelbrot_plot.png", dpi=250)</lang> |
||
A small change in the above code allows Mercator maps of the Mandelbrot set (see David Madore: [http://www.madore.org/~david/math/mandelbrot.html ''Mandelbrot set images and videos''] and Anders Sandberg: [https://www.flickr.com/photos/arenamontanus/sets/72157615740829949 ''Mercator Mandelbrot Maps'']). |
A small change in the above code allows Mercator maps of the Mandelbrot set (see David Madore: [http://www.madore.org/~david/math/mandelbrot.html ''Mandelbrot set images and videos''] and Anders Sandberg: [https://www.flickr.com/photos/arenamontanus/sets/72157615740829949 ''Mercator Mandelbrot Maps'']). |
||
The maximum magnification is exp(2*pi*h/d) = exp(2*pi*5.5) = 535.5^5.5 = 10^15, which is also the maximum for 64-bit arithmetic. |
The maximum magnification is exp(2*pi*h/d) = exp(2*pi*5.5) = 535.5^5.5 = 10^15, which is also the maximum for 64-bit arithmetic. |
||
Line 7,268: | Line 7,268: | ||
Z, dZ = np.zeros_like(C), np.zeros_like(C) |
Z, dZ = np.zeros_like(C), np.zeros_like(C) |
||
D = np.zeros(C.shape) |
T, D = np.zeros(C.shape), np.zeros(C.shape) |
||
for k in range(n): |
for k in range(n): |
||
M = abs(Z) < r |
M = abs(Z) < r |
||
Z[M], dZ[M] = Z[M] ** 2 + C[M], 2 * Z[M] * dZ[M] + 1 |
Z[M], dZ[M] = Z[M] ** 2 + C[M], 2 * Z[M] * dZ[M] + 1 |
||
T[M] = T[M] + 1 |
|||
plt.imshow(T.T ** 0.1, cmap=plt.cm.nipy_spectral_r) |
|||
N = abs(Z) > 2 |
|||
plt.savefig("Mercator_map_1.png", dpi=250) |
|||
N = abs(Z) > r # normalized iteration count |
|||
T[N] = T[N] - np.log2(np.log(abs(Z[N])) / np.log(r)) |
|||
plt.imshow(T.T ** 0.1, cmap=plt.cm.nipy_spectral_r) |
|||
plt.savefig("Mercator_map_2.png", dpi=250) |
|||
N = abs(Z) > 2 # exterior distance estimation |
|||
D[N] = 0.5 * np.log(abs(Z[N])) * abs(Z[N]) / abs(dZ[N]) |
D[N] = 0.5 * np.log(abs(Z[N])) * abs(Z[N]) / abs(dZ[N]) |
||
plt.imshow(D.T ** 0.1, cmap=plt.cm.nipy_spectral) |
plt.imshow(D.T ** 0.1, cmap=plt.cm.nipy_spectral) |
||
plt.savefig(" |
plt.savefig("Mercator_map_3.png", dpi=250) |
||
X, Y = C.real, C.imag |
X, Y = C.real, C.imag |
||
S = 150 * 2 / d * np.pi * np.exp(-B) # scaling depends on |
S = 150 * 2 / d * np.pi * np.exp(-B) # scaling depends on figsize |
||
fig, ax = plt.subplots(2, 2, figsize=(16, 16)) |
fig, ax = plt.subplots(2, 2, figsize=(16, 16)) |
||
Line 7,288: | Line 7,298: | ||
ax[1, 0].scatter(X[200:500], Y[200:500], s=S[0:300]**2, c=D[200:500]**0.3, cmap=plt.cm.nipy_spectral) |
ax[1, 0].scatter(X[200:500], Y[200:500], s=S[0:300]**2, c=D[200:500]**0.3, cmap=plt.cm.nipy_spectral) |
||
ax[1, 1].scatter(X[300:600], Y[300:600], s=S[0:300]**2, c=D[300:600]**0.2, cmap=plt.cm.nipy_spectral) |
ax[1, 1].scatter(X[300:600], Y[300:600], s=S[0:300]**2, c=D[300:600]**0.2, cmap=plt.cm.nipy_spectral) |
||
plt.savefig(" |
plt.savefig("Mandelbrot_zoom.png", dpi=250)</lang> |
||
=={{header|R}}== |
=={{header|R}}== |