# Seven Lines of Julia (examples sought)

**URL:** https://discourse.julialang.org/t/seven-lines-of-julia-examples-sought/50416
**Category:** General Usage
**Created:** [November 19, 2020, 7:37am UTC](https://discourse.julialang.org/t/seven-lines-of-julia-examples-sought/50416 "2020-11-19T07:37:29Z")
**Posts on this page:** 1
**Showing post:** 47

<div class="post-metadata">

### Author: ![FedericoStra](https://avatars.discourse-cdn.com/v4/letter/f/76d3ee/32.png) [@FedericoStra](https://discourse.julialang.org/u/FedericoStra)
#### Post date: [November 25, 2020, 4:07pm UTC](https://discourse.julialang.org/t/seven-lines-of-julia-examples-sought/50416/47 "2020-11-25T16:07:24Z")

</div>

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! 😛).

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:

```julia
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](https://i.postimg.cc/xTwtRBwM/mand.gif)), so I include only the last frame:

 ![mandelbrot](https://global.discourse-cdn.com/julialang/original/3X/a/a/aacbd246aab4dc0309873c499217d77107feb53e.jpeg)

---

_[View the full topic](https://discourse.julialang.org/t/seven-lines-of-julia-examples-sought/50416)._
