Jump to content

Mandelbrot set: Difference between revisions

Line 8,890:
plt.imshow(D ** 0.1, cmap=plt.cm.twilight_shifted)
plt.savefig("Mandelbrot_set_3.png", dpi=200)</lang>
 
A small change in the code above creates 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.
Line 8,896 ⟶ 8,897:
With the same pixel density and the same maximum magnification, the difference in height between the maps is only about 10 percent.
By misusing a scatter plot, it is possible to create zoom images of the Mandelbrot set.
To extend the zoom range beyond h > 5.5d, calculations must be performed using floating point numbers of arbitrary precision. This is currently not possible with NumPy, but can be implemented very easily in the Julia programming language (see the corresponding program example for the Julia language).
<lang python>import numpy as np
import matplotlib.pyplot as plt
Line 8,936:
import matplotlib.pyplot as plt
 
import mpmath as mpm # complex floating-point arithmetic with arbitrary precision
mpm.mp.prec = 256 # set precision to 256 bits (extended)
 
d, h = 200, 150 # pixel density (= image width) and image height
Line 8,961:
C = 5.0e-55 * (A + B * 1j)
 
Z, EdZ, dZE = np.zeros_like(C), np.zeros_like(C), np.zeros_like(C)
D = np.zeros(C.shape)
 
Line 8,978:
plt.savefig("Mandelbrot_deep_zoom.png", dpi=200)</lang>
 
Of course, deep Mercator maps can also be created. See also the image [https://www.flickr.com/photos/arenamontanus/3430921497/in/album-72157615740829949/ Deeper Mercator Mandelbrot] by Anders Sandberg. To reduce glitches, an additional reference sequence for the derivation (dS) is recorded with high precision. Compare the corresponding program examples for the Julia language for more details.
<lang python>import numpy as np
import matplotlib.pyplot as plt
 
import mpmath as mpm # complex floating-point arithmetic with arbitrary precision
mpm.mp.prec = 256 # set precision to 256 bits (extended)
 
d, h = 50, 1000 # pixel density (= image width) and image height
Line 9,007:
C = (- 4.0) * np.exp((A + B * 1j) * 1j)
 
Z, EdZ, dZE, dE = np.zeros_like(C), np.zeros_like(C), np.zeros_like(C), np.zeros_like(C)
D = np.zeros(C.shape)
 
def iteration(S, EdS, CE, dSdE, dEC):
return (2 * S + E) * E + C, 2 * ((S + E) * dE + E * dS)
 
for k in range(n):
M = Z.real ** 2 + Z.imag ** 2 < r ** 2
E[M], dE[M] = iteration(S[k], EdS[Mk], CE[M], dSdE[kM], dEC[M])
Z[M], dZ[M] = S[k+1] + E[M], dS[k+1] + dE[M]
 
305

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.