Mandelbrot set: Difference between revisions

(→‎Normalized Counting, Distance Estimation, Mercator Maps and Perturbation Theory: Finally, the rebasing can be calculated faster (about 7 times faster).)
Line 6,684:
heatmap(D' .^ 0.025, c=:nipy_spectral)
savefig("Mercator_Mandelbrot_deep_map.png")</lang>
 
The calculation can be massively accelerated again by the second reference sequence dS. To do this, only the calculation of Z and dZ has to be moved behind the loop.
<lang julia>Z, dZ, E, dE = zero(C), zero(C), zero(C), zero(C)
D, I = zeros(size(C)), ones(Int64, size(C))
 
iteration(S, dS, E, dE, C) = (2 .* S .+ E) .* E .+ C, 2 .* ((S .+ E) .* dE .+ dS .* E)
for k in 1:n
M = abs2.(E) .< abs2(r)
E[M], dE[M] = iteration(S[k], dS[k], E[M], dE[M], C[M])
I[M] = I[M] .+ 1
end
 
Z, dZ = S[I] .+ E, dS[I] .+ dE
 
N = abs.(Z) .> 2 # exterior distance estimation
D[N] = 0.5 .* log.(abs.(Z[N])) .* abs.(Z[N]) ./ abs.(dZ[N])</lang>
 
Another approach to reducing glitches is rebasing. See [https://gbillotey.github.io/Fractalshades-doc/math.html#avoiding-loss-of-precision Avoiding loss of precision] (Fractalshades) and [https://fractalforums.org/fractal-mathematics-and-new-theories/28/another-solution-to-perturbation-glitches/4360 Another solution to perturbation glitches] (Fractalforums) for details.
Line 6,718 ⟶ 6,734:
 
Z, dZ, E = zero(C), zero(C), zero(C)
D, I, J = zeros(Float64, size(C)), ones(Int64, size(C)), ones(Int64, size(C))
 
iteration(S, E, C) = (2 .* S .+ E) .* E .+ C
305

edits