Mandelbrot set: Difference between revisions

Content added Content deleted
(missed some <lang> elements)
Line 6,687: Line 6,687:
savefig("Mercator_Mandelbrot_deep_map.png")</syntaxhighlight>
savefig("Mercator_Mandelbrot_deep_map.png")</syntaxhighlight>


Due to abs(z - epsilon) < 2 and the second reference sequence, Z and dZ can be calculated after the loop. This massively reduces the computing time.
'''Speed improvement:''' Due to abs(z - epsilon) < 2 and the second reference sequence, Z and dZ can be calculated after the loop. This massively reduces the computing time.
<syntaxhighlight lang=julia>Z, dZ, E, dE = zero(C), zero(C), zero(C), zero(C)
<syntaxhighlight lang=julia>Z, dZ, E, dE = zero(C), zero(C), zero(C), zero(C)
D, I = zeros(size(C)), ones(Int64, size(C))
D, I = zeros(size(C)), ones(Int64, size(C))
Line 6,703: Line 6,703:
D[N] = 0.5 .* log.(abs.(Z[N])) .* abs.(Z[N]) ./ abs.(dZ[N])</syntaxhighlight>
D[N] = 0.5 .* log.(abs.(Z[N])) .* abs.(Z[N]) ./ abs.(dZ[N])</syntaxhighlight>


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.
'''Quality improvement:''' 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.
<syntaxhighlight lang=julia>Z, dZ, E = zero(C), zero(C), zero(C)
<syntaxhighlight lang=julia>Z, dZ, E = zero(C), zero(C), zero(C)
D, I, J = zeros(size(C)), ones(Int64, size(C)), ones(Int64, size(C))
D, I, J = zeros(size(C)), ones(Int64, size(C)), ones(Int64, size(C))


iteration(S, E, C) = (2 .* S .+ E) .* E .+ C
iteration(S, E, C) = (2 .* S .+ E) .* E .+ C
for k in 1:n # you can also try 1:2n or 1:5n due to rebasing
for k in 1:n
M = abs2.(Z) .< abs2(r)
M = abs2.(Z) .< abs2(r)
E[M] = iteration(S[I[M]], E[M], C[M])
E[M] = iteration(S[I[M]], E[M], C[M])