Mandelbrot set: Difference between revisions

Content deleted Content added
Majow (talk | contribs)
Majow (talk | contribs)
Line 7,467: Line 7,467:
===Normalized Iteration Count, Distance Estimation and Mercator Maps===
===Normalized Iteration Count, Distance Estimation and Mercator Maps===
Actually the same, but without optimizations and therefore better suited for teaching.
Actually the same, but without optimizations and therefore better suited for teaching.
The ''escape time'', ''e^(-|z|)-smoothing '', ''normalized iteration count'' and ''exterior distance estimation'' algorithms are used with NumPy and complex matrices (see Francisco Garcia, Angel Fernandez, Javier Barrallo, Luis Martin: [http://math.unipa.it/~grim/Jbarrallo.PDF ''Coloring Dynamical Systems in the Complex Plane''] and Mikael Hvidtfeldt Christensen: [http://blog.hvidtfeldts.net/index.php/2011/09/distance-estimated-3d-fractals-v-the-mandelbulb-different-de-approximations ''Distance Estimated 3D Fractals (V): The Mandelbulb & Different DE Approximations'']).
The ''e^(-|z|)-smoothing'', ''escape time'', ''normalized iteration count'' and ''exterior distance estimation'' algorithms are used with NumPy and complex matrices (see Francisco Garcia, Angel Fernandez, Javier Barrallo, Luis Martin: [http://math.unipa.it/~grim/Jbarrallo.PDF ''Coloring Dynamical Systems in the Complex Plane''] and Mikael Hvidtfeldt Christensen: [http://blog.hvidtfeldts.net/index.php/2011/09/distance-estimated-3d-fractals-v-the-mandelbulb-different-de-approximations ''Distance Estimated 3D Fractals (V): The Mandelbulb & Different DE Approximations'']).
Finally, the Mandelbrot set is also printed with a scatter plot which will be misused later for a nice effect.
Finally, the Mandelbrot set is also printed with a scatter plot which will be misused later for a nice effect.
<lang python>import numpy as np
<lang python>import numpy as np
Line 7,482: Line 7,482:


Z, dZ = np.zeros_like(C), np.zeros_like(C)
Z, dZ = np.zeros_like(C), np.zeros_like(C)
T, S, D = np.zeros(C.shape), np.zeros(C.shape), np.zeros(C.shape)
S, T, D = np.zeros(C.shape), 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
T[M], S[M] = T[M] + 1, S[M] + np.exp(-abs(Z[M]))
S[M], T[M] = S[M] + np.exp(-abs(Z[M])), T[M] + 1
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


plt.imshow(T ** 0.1, cmap=plt.cm.twilight_shifted)
plt.imshow(S ** 0.1, cmap=plt.cm.twilight_shifted)
plt.savefig("Mandelbrot_set_1.png", dpi=250)
plt.savefig("Mandelbrot_set_1.png", dpi=250)


plt.imshow(S ** 0.1, cmap=plt.cm.twilight_shifted)
plt.imshow(T ** 0.1, cmap=plt.cm.twilight_shifted)
plt.savefig("Mandelbrot_set_2.png", dpi=250)
plt.savefig("Mandelbrot_set_2.png", dpi=250)


Line 7,532: Line 7,532:


Z, dZ = np.zeros_like(C), np.zeros_like(C)
Z, dZ = np.zeros_like(C), np.zeros_like(C)
T, S, D = np.zeros(C.shape), np.zeros(C.shape), np.zeros(C.shape)
S, T, D = np.zeros(C.shape), 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
T[M], S[M] = T[M] + 1, S[M] + np.exp(-abs(Z[M]))
S[M], T[M] = S[M] + np.exp(-abs(Z[M])), T[M] + 1
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


plt.imshow(T.T ** 0.1, cmap=plt.cm.nipy_spectral_r)
plt.imshow(S.T ** 0.1, cmap=plt.cm.nipy_spectral_r)
plt.savefig("Mercator_map_1.png", dpi=250)
plt.savefig("Mercator_map_1.png", dpi=250)


plt.imshow(S.T ** 0.1, cmap=plt.cm.nipy_spectral_r)
plt.imshow(T.T ** 0.1, cmap=plt.cm.nipy_spectral_r)
plt.savefig("Mercator_map_2.png", dpi=250)
plt.savefig("Mercator_map_2.png", dpi=250)