Mandelbrot set: Difference between revisions
Content added Content deleted
(→Normalized Counting, Distance Estimation, Mercator Maps and Perturbation Theory: Addition to reduce image errors caused by the reference sequence.) |
(→Normalized Counting, Distance Estimation, Mercator Maps and Perturbation Theory: Removed redundant version) |
||
Line 6,575: | Line 6,575: | ||
savefig("Mercator_Mandelbrot_map_2.png")</lang> |
savefig("Mercator_Mandelbrot_map_2.png")</lang> |
||
To get even faster, it is enough to calculate a single point with high accuracy. A more or less good approximation can then be found for all other points by means of a perturbation calculation with less accuracy. See [https://en.wikipedia.org/wiki/Plotting_algorithms_for_the_Mandelbrot_set#Perturbation_theory_and_series_approximation Perturbation Theory] ( |
To get even faster, it is enough to calculate a single point with high accuracy. A more or less good approximation can then be found for all other points by means of a perturbation calculation with less accuracy. See [https://en.wikipedia.org/wiki/Plotting_algorithms_for_the_Mandelbrot_set#Perturbation_theory_and_series_approximation Perturbation Theory] (Wikipedia) and [https://gbillotey.github.io/Fractalshades-doc/math.html Mathematical Background] (Fractalshades) for more details. For extreme magnifications, the reference series must also be saved with greater accuracy. All you have to do is change the line ''Zeta = zeros(Complex{Double64}, n)'' and use the DoubleFloats library. Surprisingly, the DoubleFloats are faster than the MultiFloats in this context. In order to reduce the image errors, an additional reference sequence for the derivations should be recorded with high accuracy. |
||
<lang julia>using Plots |
<lang julia>using Plots |
||
gr(aspect_ratio=:equal, axis=true, ticks=true, legend=false, dpi=200) |
gr(aspect_ratio=:equal, axis=true, ticks=true, legend=false, dpi=200) |
||
Line 6,589: | Line 6,589: | ||
c = a + b * im |
c = a + b * im |
||
z = zero(c) |
z, dz = zero(c), zero(c) |
||
Zeta = zeros(Complex{Float64}, n+1) # calculation of the reference sequence (Zeta) |
|||
for k in 1:n+1 |
|||
Zeta[k] = z |
|||
z = z ^ 2 + c |
|||
if abs2(z) > abs2(r) |
|||
error("n is too large: reference sequence diverges for reference point c!") |
|||
end |
|||
end |
|||
x = range(0, 2, length=d+1) |
|||
y = range(0, 2 * h / d, length=h+1) |
|||
A, B = collect(x .* pi), collect(y .* pi) |
|||
Delta = (.- 4.0) .* exp.((A' .+ B .* im) .* im) |
|||
Z, dZ, Epsilon = zero(Delta), zero(Delta), zero(Delta) |
|||
D = zeros(size(Delta)) |
|||
for k in 1:n |
|||
M = abs2.(Z) .< abs2(r) |
|||
Epsilon[M] = 2 .* Zeta[k] .* Epsilon[M] .+ Epsilon[M] .^ 2 .+ Delta[M] |
|||
Z[M], dZ[M] = Zeta[k+1] .+ Epsilon[M], 2 .* Z[M] .* dZ[M] .+ 1 |
|||
end |
|||
N = abs.(Z) .> 2 # exterior distance estimation |
|||
D[N] = 0.5 .* log.(abs.(Z[N])) .* abs.(Z[N]) ./ abs.(dZ[N]) |
|||
heatmap(D' .^ 0.025, c=:nipy_spectral) |
|||
savefig("Mercator_Mercator_map_3.png")</lang> |
|||
In order to reduce the image errors due to the reference sequence, an additional reference sequence for the derivations can be recorded with high accuracy. |
|||
<lang julia>using Plots |
|||
gr(aspect_ratio=:equal, axis=true, ticks=true, legend=false, dpi=200) |
|||
setprecision(BigFloat, 256) # set precision to 256 bits (default) |
|||
setrounding(BigFloat, RoundNearest) # set rounding mode (default) |
|||
d, h = 50, 1000 # pixel density (= image width) and image height |
|||
n, r = 50000, 100000 # number of iterations and escape radius (r > 2) |
|||
a = BigFloat("-1.256827152259138864846434197797294538253477389787308085590211144291") |
|||
b = BigFloat(".37933802890364143684096784819544060002129071484943239316486643285025") |
|||
c = a + b * im |
|||
z = zero(c) |
|||
Zeta, dZeta = zeros(Complex{Float64}, n+1), zeros(Complex{Float64}, n+1) # reference sequences |
Zeta, dZeta = zeros(Complex{Float64}, n+1), zeros(Complex{Float64}, n+1) # reference sequences |
||
Line 6,666: | Line 6,620: | ||
heatmap(D' .^ 0.025, c=:nipy_spectral) |
heatmap(D' .^ 0.025, c=:nipy_spectral) |
||
savefig(" |
savefig("Mercator_Mercator_map_3.png")</lang> |
||
=={{header|Kotlin}}== |
=={{header|Kotlin}}== |