Mandelbrot set: Difference between revisions

Content added Content deleted
(→‎Normalized Counting, Distance Estimation, Mercator Maps and Perturbation Theory: Added original source for rebasing and avoided millions of unnecessary abs2(r) calculations)
Line 6,683: Line 6,683:
savefig("Mercator_Mandelbrot_deep_map.png")</lang>
savefig("Mercator_Mandelbrot_deep_map.png")</lang>


Another approach to reduce the glitches is the so-called ''rebasing''. See [https://gbillotey.github.io/Fractalshades-doc/math.html#avoiding-loss-of-precision Avoiding loss of precision] (Fractalshades) for details.
Another approach to reduce the glitches is the so-called ''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.
<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,717: Line 6,717:
D = zeros(size(C))
D = zeros(size(C))


abs2_r = abs2(r)
for i in 1:h+1, j in 1:d+1
for i in 1:h+1, j in 1:d+1
z, dz, epsilon = Z[i, j], dZ[i, j], E[i, j]
z, dz, epsilon = Z[i, j], dZ[i, j], E[i, j]
Line 6,723: Line 6,724:
epsilon = (2 * S[index] + epsilon) * epsilon + delta
epsilon = (2 * S[index] + epsilon) * epsilon + delta
z, dz = S[index + 1] + epsilon, 2 * z * dz + 1
z, dz = S[index + 1] + epsilon, 2 * z * dz + 1
if abs2(z) > abs2(r)
abs2_z, abs2_epsilon = abs2(z), abs2(epsilon)
if abs2_z < abs2_epsilon # rebasing when orbit is near zero
epsilon, index = z, 1
elseif abs2_z < abs2_r
index = index + 1
else
break
break
end
index = index + 1
if abs2(z) < abs2(epsilon) # rebasing when orbit is near zero
epsilon, index = z, 1
end
end
end
end
Line 6,738: Line 6,740:


heatmap(D' .^ 0.025, c=:nipy_spectral)
heatmap(D' .^ 0.025, c=:nipy_spectral)
savefig("Mercator_Mandelbrot_rebase_map.png")</lang>
savefig("Mercator_Mandelbrot_base_map.png")</lang>


The images can be verified by a (slow) calculation with BigFloats. There are libraries that are faster than BigFloats, for example DoubleFloats.jl and MultiFloats.jl. Unfortunately, the precision of the DoubleFloats is not sufficient, and only the double MultiFloats (Float64x2) are fast. For deep zoom images you need at least triple or quadruple MultiFloats (Float64x3, Float64x4), but they are slower than BigFloats.
The images can be verified by a (slow) calculation with BigFloats. There are libraries that are faster than BigFloats, for example DoubleFloats.jl and MultiFloats.jl. Unfortunately, the precision of the DoubleFloats is not sufficient, and only the double MultiFloats (Float64x2) are fast. For deep zoom images you need at least triple or quadruple MultiFloats (Float64x3, Float64x4), but these are slower than BigFloats.
<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,773: Line 6,775:


heatmap(D' .^ 0.025, c=:nipy_spectral)
heatmap(D' .^ 0.025, c=:nipy_spectral)
savefig("Mercator_Mandelbrot_bigfloat_map.png")</lang>
savefig("Mercator_Mandelbrot_big_map.png")</lang>


=={{header|Kotlin}}==
=={{header|Kotlin}}==