Mandelbrot set: Difference between revisions

→‎Normalized Counting, Distance Estimation, Mercator Maps and Perturbation Theory: Only Float64x2 are fast, but you need at least Float64x3. Therefore, the MultiFloats example has been replaced and superfluous whitespace has been deleted.
(→‎Normalized Counting, Distance Estimation, Mercator Maps and Perturbation Theory: Only Float64x2 are fast, but you need at least Float64x3. Therefore, the MultiFloats example has been replaced and superfluous whitespace has been deleted.)
Line 6,633:
D = zeros(size(C))
 
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
for j in 1:d+1
zdelta, dz, epsilonindex = ZC[i, j], dZ[i, j], E[i, j]1
for k delta, index = C[i, j],in 1:n
epsilon = (2 z, dz =* S[index + 1] + epsilon, 2) * z * dzepsilon + 1delta
for k in 1:n
z, epsilondz = (2 * S[index + 1] + epsilon), 2 * epsilonz * dz + delta1
if abs2(z) > abs2(r)
z, dz = S[index + 1] + epsilon, 2 * z * dz + 1
if abs2(z) > abs2(r)break
breakend
index = index + end1
if abs2(z) < abs2(epsilon) index =# indexrebasing +when 1orbit is near zero
if abs2(z) < abs2(epsilon), index #= rebasing when orbit is nearz, zero1
epsilon, index = z, 1
end
end
Z[i, j], dZ[i, j], E[i, j] = z, dz, epsilon
end
Z[i, j], dZ[i, j], E[i, j] = z, dz, epsilon
end
 
Line 6,656 ⟶ 6,654:
 
heatmap(D' .^ 0.025, c=:nipy_spectral)
savefig("Mercator_Mandelbrot_rebasing_mapMercator_Mandelbrot_rebase_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 MultiFloats.jl library can be used to verify the results. To do this, however, the complex exponential function must be broken down into real cosine and sine functions and these functions must be calculated with BigFloats. However, the one-off calculation with a few BigFloats before and after the loop only has a small impact on the calculation speed. Since the number pi is missing from the library, 2*pi is replaced by acos(0)*4. Although the calculation with MultiFloats is much faster than with BigFloats, it is much slower compared to the perturbation calculation.
<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)
using MultiFloats
setrounding(BigFloat, RoundNearest) # set rounding mode (default)
MultiFloats.use_bigfloat_transcendentals()
 
d, h = 10, 200 # pixel density (= image width) and image height
n, r = 60000, 100000 # number of iterations and escape radius (r > 2)
a = Float64x3("-1.256827152259138864846434197797294538253477389787308085590211144291")
b = Float64x3(".37933802890364143684096784819544060002129071484943239316486643285025")
 
a = Float64x3BigFloat("-1.256827152259138864846434197797294538253477389787308085590211144291")
x = range(zero(a), acos(zero(a)) * 4, length=d+1)
b = Float64x3BigFloat(".37933802890364143684096784819544060002129071484943239316486643285025")
y = range(zero(b), acos(zero(b)) * 4 * h / d, length=h+1)
 
x = range(zero(a), acos(zeroone(a)) * 42, length=d+1)
y = range(zero(b), acos(zeroone(b)) * 42 * h / d, length=h+1)
 
A, B = collect(x .* pi), collect(y .* pi)
C = (.- 4.0) .* (cosexp.((A)' .-+ sin.(A)B .* im)' .* exp.(.- Bim) .+ a .+ b .* im
 
Z, dZ = zero(C), zero(C)
Line 6,691 ⟶ 6,689:
 
heatmap(D' .^ 0.025, c=:nipy_spectral)
savefig("Mercator_Mandelbrot_multifloats_mapMercator_Mandelbrot_bigfloat_map.png")</lang>
 
=={{header|Kotlin}}==
305

edits