Mandelbrot set: Difference between revisions

Line 6,536:
C = 5.0e-55 .* (A' .+ B .* im)
 
Z, EdZ, dZE = zero(C), zero(C), zero(C)
D = zeros(size(C))
 
Line 6,583:
C = (.- 4.0) .* exp.((A' .+ B .* im) .* im)
 
Z, EdZ, dZE, dE = zero(C), zero(C), zero(C), zero(C)
D = zeros(size(C))
 
iteration(S, EdS, CE, dSdE, dEC) = (2 .* S .+ E) .* E .+ C, 2 .* ((S .+ E) .* dE .+ E .* dS)
for k in 1:n
M = abs2.(Z) .< abs2(r)
E[M], dE[M] = iteration(S[k], EdS[Mk], CE[M], dSdE[kM], dEC[M])
Z[M], dZ[M] = S[k+1] .+ E[M], dS[k+1] .+ dE[M]
end
Line 6,615:
z = zero(c)
 
S = zeros(Complex{Float64}, n+1) # calculation of the reference sequence (S)
for k in 1:n+1
S[k] = z
z = z ^ 2 + c
if abs2(z) > abs2(r)
error("ERROR: n is too large (reference sequence diverges for reference point c)!")
end
end
Line 6,639:
for k in 1:n
epsilon = (2 * S[index] + epsilon) * epsilon + delta
z, dz = S[index + 1] + epsilon, 2 * z * dz + 1
index = index + 1
if abs2(z) > abs2(r)
break
end
ifindex abs2(z)= <index abs2(epsilon)+ # rebase when orbit is near zero1
if abs2(z) < abs2(epsilon) # rebasing when orbit is near zero
epsilon, index = z, 1
end
Line 6,656:
 
heatmap(D' .^ 0.025, c=:nipy_spectral)
savefig("Mercator_Mandelbrot_rebased_mapMercator_Mandelbrot_rebasing_map.png")</lang>
 
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.
Line 6,691:
 
heatmap(D' .^ 0.025, c=:nipy_spectral)
savefig("Mercator_Mandelbrot_verify_mapMercator_Mandelbrot_multifloats_map.png")</lang>
 
=={{header|Kotlin}}==
305

edits