Seven Lines of Julia (examples sought)

Nice! I was thinking of doing something similar, but I couldn’t find the time, nor fit it in less than 7 lines (you cheated! :stuck_out_tongue:).

I think that, to make it better, the number of iterations in mandelbrot has to increase the more one zooms in, otherwise the boundary of the fractal becomes too imprecise. Here is a complete version that does so:

using Plots
exprange(start, stop, len) = exp.(range(log(start), log(stop), length=len))
function mandelbrot(z; lim=75) w = z
    for n = 1:lim;  abs2(w) < 4 ? w = w^2 + z : return n end
    lim + 1
end
x₀, y₀ = -0.5626805, 0.6422555
anim = @animate for (r, l) in zip(exprange(2, 1.35e-6, 120), exprange(100, 2500, 120))
    x = range(x₀-r, x₀+r; length=600); y = range(y₀-r, y₀+r; length=600);
    heatmap(x, y, -log.(log.(mandelbrot.(x' .+ y .* im; lim=round(l))));
        legend=:none, border=:none, ticks=:none, size=(600,600), ratio=1)
end
g = gif(anim; fps=12)

Apparently I cannot attach the animated GIF file (which you can find here), so I include only the last frame:

10 Likes