# \[ANN\] Fatou.jl : Easily share Julia fractals

**URL:** <https://discourse.julialang.org/t/ann-fatou-jl-easily-share-julia-fractals/12278>\
**Category:** Community\
**Tags:** package, announcement, plotting, fractal\
**Created:** [July 9, 2018, 5:30pm UTC](https://discourse.julialang.org/t/ann-fatou-jl-easily-share-julia-fractals/12278 "2018-07-09T17:30:04Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![chakravala](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chakravala/32/6832_2.png) [@chakravala](https://discourse.julialang.org/u/chakravala)\
**Post date:** [July 9, 2018, 5:30pm UTC](https://discourse.julialang.org/t/ann-fatou-jl-easily-share-julia-fractals/12278/1 "2018-07-09T17:30:04Z")

</div>

This package enables users of Julia lang to easily generate, explore, and share fractals of Julia, Mandelbrot, and Newton type. The name `Fatou` comes from the mathematician after whom the Fatou sets are named.

**Definition** _(Julia set)_: For any holomorphic function on a complex plane, the boundary of the set of points whose result diverges when the function is iteratively evaluated at each point.

**Definition** _(Fatou set)_: The Julia set’s complement is the set of fixed limit points from holomorphic recursion.

**Definition** _(Mandelbrot set)_: The set of points on a complex parameter space for which the holomorphic recursion does not go to infinity from a common starting poin z\_0.

**Definition** _(Newton fractal)_: The Julia/Fatou set obtained from the recursion of the Newton method z \mapsto z - m\cdot f(z) / f'(z) applied to a holomorphic function.

> **[GitHub - chakravala/Fatou.jl: Fatou sets in Julia (Fractals, Newton basins,...](https://github.com/chakravala/Fatou.jl)**
>
> Fatou sets in Julia (Fractals, Newton basins, Mandelbrot) - GitHub - chakravala/Fatou.jl: Fatou sets in Julia (Fractals, Newton basins, Mandelbrot)

This package is supported on versions 0.5 to 0.7, and the newest release for 0.6 and 0.7 now relies on Reduce for symbolic computations with the Newton scheme.

> [@\[ANN\] Reduce.jl : Symbolic CAS parser-interface](https://discourse.julialang.org/t/ann-reduce-jl-symbolic-cas-parser-interface/11452):
>
> [logo] [REDUCE](http://www.reduce-algebra.com/) is a portable general-purpose computer algebra system. This package enables users of Julia to use this programmable CAS inside Julia with methods that automatically parse queries and their output. It currently supports both 0.6 and 0.7 version of Julia. See README and [docs](https://chakravala.github.io/Reduce.jl/latest) for examples. At this point in the development of this module, there should be enough documentation with examples available for users to see what they can do with it. The way it currently works is by piping …

See the [wiki](https://github.com/chakravala/Fatou.jl/wiki/Explore-Fatou-sets-&-fractals) for many more detailed examples. Here is one of my own discovered examples

```Julia
plot(mandelbrot(:(e^(-z)+cos(c)+im*sin(c*z)),∂=[-π,π,-2,2],n=700,N=80,cmap="jet",iter=false,p=-0.3) |> fatou, bare=true)

```

![outc](https://global.discourse-cdn.com/julialang/original/2X/8/8b9a624ce3ec4d4f3e76b55b99299b0682f63bdd.png)

This is my favorite fractal made with the `Fatou` package so far, I was completely surprised by what kind of crazy images you can make with this, using the function e^{-z} + \cos(c) + \sqrt{-1}\cdot\sin(c\cdot z) .

Also, if somebody has a good suggestion about how to make this package independent of PyPlot, while still retaining the same color maps that are available from PyPlot, then I am open to ideas and suggestions.

_It would be awesome if other Julians could post some of their own discoveries made with this package._

---

<div class="post-metadata">

**Author:** ![NiclasMattsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/niclasmattsson/32/21988_2.png) [@NiclasMattsson](https://discourse.julialang.org/u/NiclasMattsson)\
**Post date:** [July 9, 2018, 7:36pm UTC](https://discourse.julialang.org/t/ann-fatou-jl-easily-share-julia-fractals/12278/2 "2018-07-09T19:36:14Z")

</div>

Cool package! I’m a bit confused about the [Mandelbrot image in the wiki](https://raw.githubusercontent.com/wiki/chakravala/Fatou.jl/img/mandelbrot.png) though. Usually the Mandelbrot set is colored on the outside of the set using the number of iterations required to escape. But I’ve never seen the Mandelbrot set colored on the inside before. What metric are you using to do this?

---

<div class="post-metadata">

**Author:** ![chakravala](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chakravala/32/6832_2.png) [@chakravala](https://discourse.julialang.org/u/chakravala)\
**Post date:** [July 9, 2018, 7:39pm UTC](https://discourse.julialang.org/t/ann-fatou-jl-easily-share-julia-fractals/12278/3 "2018-07-09T19:39:58Z")

</div>

That’s a great question, yes normally the inside is not colored, but that is boring to the eyes!

You can find out the default information for `mandelbrot` in the help system

```nohighlight
help?> mandelbrot
search: mandelbrot

  mandelbrot(::Expr; # primary map, (z, c) -> F
    Q::Expr = :(abs2(z)), # escape criterion, (z, c) -> Q
    C::Expr = :(exp(-abs(z))*n^p), # coloring, (z, n=iter., p=exp.) -> C
    ∂ = π/2, # Array{Float64,1} # Bounds, [x(a),x(b),y(a),y(b)]
    n::Integer = 176, # horizontal grid points
    N::Integer = 35, # max. iterations
    ϵ::Number = 4, # basin ϵ-Limit criterion
    iter::Bool = false, # toggle iteration mode
    p::Number = 0, # iteration color exponent
    m::Number = 0, # Newton multiplicity factor
    seed::Number= 0.0+0.0im, # Mandelbrot seed value
    x0 = nothing, # orbit starting point
    orbit::Int = 0, # orbit cobweb depth
    depth::Int = 1, # depth of function composition
    cmap::String= "") # imshow color map

  Define Mandelbrot basin in Fatou

```

and you can in fact use any of your own metrics for it via the keywords.

---

<div class="post-metadata">

**Author:** ![chakravala](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chakravala/32/6832_2.png) [@chakravala](https://discourse.julialang.org/u/chakravala)\
**Post date:** [July 9, 2018, 8:43pm UTC](https://discourse.julialang.org/t/ann-fatou-jl-easily-share-julia-fractals/12278/4 "2018-07-09T20:43:35Z")

</div>

> [@NiclasMattsson](#):
>
> Usually the Mandelbrot set is colored on the outside of the set using the number of iterations required to escape. But I’ve never seen the Mandelbrot set colored on the inside before. What metric are you using to do this?

To answer this question specifically, `Fatou` has essentially two different plotting modes controlled by the `iter` boolean keyword. In the example you referenced, the coloring function e^{-|z|}\cdot n^p is used with the limit values of z, which causes a coloring value that also varies on the inside of the set.

However, if you want to get the traditional iteration count display of the Mandelbrot set, then you need to set the `iter` keyword to `true` as such

```Julia
mandelbrot(:(z^2+c),n=700,N=20,∂=[-1.91,0.51,-1.21,1.21],iter=true,cmap="gist_earth") |> fatou |> plot

```

![mandel](https://global.discourse-cdn.com/julialang/original/3X/b/4/b4b2138b0786cec2387021c08a03d90c3dcd94a7.png)

Then the coloring scheme works as you typically expect it. The title of the plot tells you what kind it is.

---

<div class="post-metadata">

**Author:** ![chakravala](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chakravala/32/6832_2.png) [@chakravala](https://discourse.julialang.org/u/chakravala)\
**Post date:** [October 3, 2018, 12:29pm UTC](https://discourse.julialang.org/t/ann-fatou-jl-easily-share-julia-fractals/12278/5 "2018-10-03T12:29:28Z")

</div>

Hooray! With the release of Julia 1.0.1, the `Fatou` package finally works again. There was a compatibility issue that prevented it from working in Julia 1.0, so you will need to use 1.0.1 to run `Fatou`. Also, there will be a stackoverflow error if you only have `using Fatou`, this can be avoided by saying `using Reduce,Fatou`.

Would be awesome if some people could post code snippets here for their favorite fractal discoveries.

---

<div class="post-metadata">

**Author:** ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)\
**Post date:** [October 3, 2018, 12:52pm UTC](https://discourse.julialang.org/t/ann-fatou-jl-easily-share-julia-fractals/12278/6 "2018-10-03T12:52:49Z")

</div>

Out of curiosity, have you experienced with multi-threading for evaluating each pixel (I see some `Threads` stuff so I guess, yes) and how have you found the scaling to be?

---

<div class="post-metadata">

**Author:** ![chakravala](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chakravala/32/6832_2.png) [@chakravala](https://discourse.julialang.org/u/chakravala)\
**Post date:** [October 3, 2018, 12:58pm UTC](https://discourse.julialang.org/t/ann-fatou-jl-easily-share-julia-fractals/12278/7 "2018-10-03T12:58:05Z")

</div>

Yes, indeed, `Fatou` detects the number of Julia threads available at the startup and reports it back. When a specified Fatou set is computed, multi-threading is used to compute the pixels. If you have 8 threads, then the computation will be 8 times faster. Since each pixel is independent of any other pixel, it doesn’t matter in what order or on how many threads it is computed, the more you use the faster it is. I have this in `startup.jl`

```nohighlight
ENV["JULIA_NUM_THREADS"] = 8

```

This enables the multi-threading for more than 1 thread. Here is the code

[https://github.com/chakravala/Fatou.jl/blob/master/src/Fatou.jl#L271-L273](https://github.com/chakravala/Fatou.jl/blob/master/src/Fatou.jl#L271-L273)

---

<div class="post-metadata">

**Author:** ![j605](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/j605/32/2130_2.png) [@j605](https://discourse.julialang.org/u/j605)\
**Post date:** [October 7, 2018, 3:08pm UTC](https://discourse.julialang.org/t/ann-fatou-jl-easily-share-julia-fractals/12278/8 "2018-10-07T15:08:07Z")

</div>

Maybe off topic but I am unable to install it in 1.0.1. It fails with following error

```julia
(v1.0) pkg> add Fatou
  Updating registry at `~/.julia/registries/General`
  Updating git-repo `https://github.com/JuliaRegistries/General.git`
 Resolving package versions...
ERROR: Unsatisfiable requirements detected for package Fatou [5f923234]:
 Fatou [5f923234] log:
 ├─possible versions are: [0.0.1-0.0.3, 0.1.0-0.1.3, 0.2.0, 1.0.0] or uninstalled
 ├─restricted to versions * by an explicit requirement, leaving only versions [0.0.1-0.0.3, 0.1.0-0.1.3, 0.2.0, 1.0.0]
 └─restricted by julia compatibility requirements to versions: uninstalled — no versions left

```

---

<div class="post-metadata">

**Author:** ![chakravala](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chakravala/32/6832_2.png) [@chakravala](https://discourse.julialang.org/u/chakravala)\
**Post date:** [October 7, 2018, 3:16pm UTC](https://discourse.julialang.org/t/ann-fatou-jl-easily-share-julia-fractals/12278/9 "2018-10-07T15:16:11Z")

</div>

Not sure what is the cause of that. Have you tried with `dev Fatou` instead?

---

<div class="post-metadata">

**Author:** ![j605](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/j605/32/2130_2.png) [@j605](https://discourse.julialang.org/u/j605)\
**Post date:** [October 7, 2018, 4:06pm UTC](https://discourse.julialang.org/t/ann-fatou-jl-easily-share-julia-fractals/12278/10 "2018-10-07T16:06:06Z")

</div>

`dev Fatou` works. I checked the metadata repo and it was updated there so I didn’t know what has caused the error in my previous message.

---

<div class="post-metadata">

**Author:** ![chakravala](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chakravala/32/6832_2.png) [@chakravala](https://discourse.julialang.org/u/chakravala)\
**Post date:** [December 15, 2018, 5:13pm UTC](https://discourse.julialang.org/t/ann-fatou-jl-easily-share-julia-fractals/12278/11 "2018-12-15T17:13:11Z")

</div>

This is an announcement update, `Fatou` version 1.0.1 has been released, which now has a significant performance improvement due to the suggestion by @ckoe-bccms with parametric types

> [@Structs and parametric constructors](https://discourse.julialang.org/t/structs-and-parametric-constructors/18684/12):
>
> When I only add the Function parameters to the Define type, I get basically 0% to 10% improvement. My original timings look like this julia\> newton(:(z^3-1);n=500)|\>fatou; 0.240635 seconds (1.69 M allocations: 58.407 MiB) With the Define{FT\<:Function,QT\<:Function,CT\<:Function} definition, I don’t get much improvement julia\> newton(:(z^3-1);n=500)|\>fatou; 0.221504 seconds (1.53 M allocations: 50.724 MiB) However, because in my situation there is additional program logic, I added additio…

This should fix the issue with the high memory allocation for large n, allowing bigger fractals, faster

```Julia
julia> newton(:(z^3-1);n=3500)|>fatou;
  1.004239 seconds (541 allocations: 36.706 KiB)

```

The testing behavior of the package is a bit weird on some platforms, but with `PyPlot`, it should work.

---

<div class="post-metadata">

**Author:** ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)\
**Post date:** [December 15, 2018, 5:23pm UTC](https://discourse.julialang.org/t/ann-fatou-jl-easily-share-julia-fractals/12278/12 "2018-12-15T17:23:29Z")

</div>

Out of curiosity, what was the timing before type parameters, for running that code?

---

<div class="post-metadata">

**Author:** ![chakravala](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chakravala/32/6832_2.png) [@chakravala](https://discourse.julialang.org/u/chakravala)\
**Post date:** [December 15, 2018, 5:28pm UTC](https://discourse.julialang.org/t/ann-fatou-jl-easily-share-julia-fractals/12278/13 "2018-12-15T17:28:59Z")

</div>

> [@kristoffer.carlsson](#):
>
> Out of curiosity, what was the timing before type parameters, for running that code?

In this post, I had a comparison of n=1500 grid, which took 19 seconds before, while only taking 0.17 seconds in the new version with the parametric types.

> [@Structs and parametric constructors](https://discourse.julialang.org/t/structs-and-parametric-constructors/18684/14):
>
> Well, I am a german speaker also, but probably not everyone on this website is. What you could do is write a single while loop, which has the if statement inside the condition, as I have done in my code shown above. Amazingly, with this improvement the difference is enormous for larger n, with old definition julia\> newton(:(z^3-1);n=1500)|\>fatou; 19.215167 seconds (65.07 M allocations: 1.817 GiB, 7.66% gc time) However, with new definition julia\> newton(:(z^3-1);n=1500)|\>fatou; 0.175065…

It’s probably due to assigning the `Fatou.Define` object to parallel threads, because the iteration function depends on two `Bool` values in that object and also functions in it, which might become unnecessary now due to the information provided by the parametric type. Now, only the complex number is variable.

---

<div class="post-metadata">

**Author:** ![chakravala](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chakravala/32/6832_2.png) [@chakravala](https://discourse.julialang.org/u/chakravala)\
**Post date:** [December 16, 2018, 1:17am UTC](https://discourse.julialang.org/t/ann-fatou-jl-easily-share-julia-fractals/12278/14 "2018-12-16T01:17:51Z")

</div>

This here is a fractal which is notoriously difficult to calculate, now it can be calculated at higher resolution

```plaintext
newton(:(z^(4.0+3.0im)-1),m=2.1,∂=π,n=2000,N=27,cmap="terrain") |> fatou |> plot
 13.986463 seconds (541 allocations: 36.706 KiB)

```

With these improvements, it still takes 14 seconds for 2000 pixels, but previously 500 pixels was reasonable

![complex-fractal](https://global.discourse-cdn.com/julialang/original/3X/d/1/d108dd3984a5dc5b5d3ef6407baa7c25ddad6ccf.png)

That is using `N=27` iterations maximum. This one is a slow fractal to compute. Post some more fractals!

---

<div class="post-metadata">

**Author:** ![chakravala](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chakravala/32/6832_2.png) [@chakravala](https://discourse.julialang.org/u/chakravala)\
**Post date:** [January 20, 2019, 4:05am UTC](https://discourse.julialang.org/t/ann-fatou-jl-easily-share-julia-fractals/12278/15 "2019-01-20T04:05:43Z")

</div>

The newly tagged release of `Fatou` enables support for `ImageInTerminal` and deprecates the requirement for having `PyPlot` on your Julia installation. However, it continues to support PyPlot if it is installed.

 ![Screenshot_2019-01-19_22-51-00](https://global.discourse-cdn.com/julialang/original/3X/c/d/cde8661bb36f1b0f1395170a1a1f07a1dc380820.png)

Here’s what `ImageInTerminal` looks like with some `Fatou.FilledSet` displayed.

If you want your favorite plotting program to be compatible, you are welcome to make a PR

---

<div class="post-metadata">

**Author:** ![mkborregaard](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkborregaard/32/556_2.png) [@mkborregaard](https://discourse.julialang.org/u/mkborregaard)\
**Post date:** [January 20, 2019, 9:21am UTC](https://discourse.julialang.org/t/ann-fatou-jl-easily-share-julia-fractals/12278/16 "2019-01-20T09:21:27Z")

</div>

> [@chakravala](#):
>
> f somebody has a good suggestion about how to make this package independent of PyPlot, while still retaining the same color maps that are available from PyPlot

I mean you could implement the plotting with recipes instead. All that is needed is RecipesBase, which is 200 loc with zero dependencies and no exports, and then the user would need Plots to plot it.  
There are lots of colormaps available: [Colors · Plots](https://docs.juliaplots.org/latest/colors/#colorschemes)  
If the color gradients from matplotlib can be made available within the MIT license here we would be happy to take a PR adding them so that this functionality becomes available. But - the jet, cubehelix and gist\_earth color schemes are not perceptually uniform. Why do you choose this set of palettes?

---

<div class="post-metadata">

**Author:** ![chakravala](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chakravala/32/6832_2.png) [@chakravala](https://discourse.julialang.org/u/chakravala)\
**Post date:** [January 20, 2019, 10:59am UTC](https://discourse.julialang.org/t/ann-fatou-jl-easily-share-julia-fractals/12278/17 "2019-01-20T10:59:09Z")

</div>

> [@mkborregaard](#):
>
> There are lots of colormaps available: [Colors · Plots](https://docs.juliaplots.org/latest/colors/#colorschemes)  
> If the color gradients from matplotlib can be made available within the MIT license here we would be happy to take a PR adding them so that this functionality becomes available. But - the jet, cubehelix and gist\_earth color schemes are not perceptually uniform. Why do you choose this set of palettes?

To summarize, the reason why I used PyPlot is because it has lots of nice color maps, that’s why I made the package specifically compatible with PyPlot and not Plots, but anyone is welcome to add `Plots` support.

RecipesBase looks interesting, perhaps I will add that feature soon

I choose those color schemes on purpose, because I think they look the most interesting for fractals.

Some of them like `jet,cubehelix` are already available with `ColorSchemes`, but `gist_earth` is not available yet. The ColorSchemes can be used for `ImageInTerminal`, while the matplotlib are used for PyPlot. A large amount of them are compatible, but not all of them. I would like to see more also.

---

<div class="post-metadata">

**Author:** ![mkborregaard](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkborregaard/32/556_2.png) [@mkborregaard](https://discourse.julialang.org/u/mkborregaard)\
**Post date:** [January 20, 2019, 12:45pm UTC](https://discourse.julialang.org/t/ann-fatou-jl-easily-share-julia-fractals/12278/18 "2019-01-20T12:45:47Z")

</div>

Great! I can see your colours do look interesting for fractals. If you do attempt to write recipes I think we could put those three in the misc library

---

<div class="post-metadata">

**Author:** ![cormullion](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cormullion/32/49131_2.png) [@cormullion](https://discourse.julialang.org/u/cormullion)\
**Post date:** [January 20, 2019, 5:20pm UTC](https://discourse.julialang.org/t/ann-fatou-jl-easily-share-julia-fractals/12278/19 "2019-01-20T17:20:02Z")

</div>

> [@chakravala](#):
>
> Some of them like `jet,cubehelix` are already available with `ColorSchemes` , but `gist_earth` is not available yet.

I can easily add new schemes to [ColorSchemes.jl](https://github.com/JuliaGraphics/ColorSchemes.jl), I just ran out of ideas for new ones… 🙂

---

<div class="post-metadata">

**Author:** ![chakravala](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chakravala/32/6832_2.png) [@chakravala](https://discourse.julialang.org/u/chakravala)\
**Post date:** [January 20, 2019, 5:44pm UTC](https://discourse.julialang.org/t/ann-fatou-jl-easily-share-julia-fractals/12278/20 "2019-01-20T17:44:05Z")

</div>

> [@cormullion](#):
>
> I can easily add new schemes to [ColorSchemes.jl](https://github.com/JuliaGraphics/ColorSchemes.jl), I just ran out of ideas for new ones… 🙂

Could you add the missing ones from here [https://matplotlib.org/examples/color/colormaps\_reference.html](https://matplotlib.org/examples/color/colormaps_reference.html)

For example, such as `ocean`, `gist_earth`, `gnuplot` which are all missing, then color maps will be much more portable across different plotting environments.

[Next page](https://discourse.julialang.org/t/ann-fatou-jl-easily-share-julia-fractals/12278.md?page=2)
