A Hobbyist Introduction to Julia and Mandelbrot Sets

A while ago I have been recreationally exploring Multibrot sets and discovered a few very interesting things that I have not seen being observed or explained anywhere (at least, it seems not to be common knowledge). As usual, other things came in the way, but I am still planning to write a post or two to document and wrap up these observations.

In this post, which I have been sitting on for almost a year, I just want to give a brief, incomplete and non-rigorous introduction to these very well-known and popular fractals. Of course there is a (frighteningly) large amount of material already, written from different perspectives and targeting different audiences. This is therefore mostly a personal summary from my attempt of navigating and understanding the key aspects of the topic. It is intended as an entry point, with links to other relevant pages and resources for further exploration.

Introduction: Boring and Not So Boring Fractals

There seems to be no accepted rigorous definition of what a fractal actually is, except for some very general properties shared by different instances of fractal patterns – such as self-similarity and intricate structure at arbitrary scales. I won’t waste time illustrating the ubiquity of fractal-like structures in nature, as there are lots of books and articles written on this topic.

There are many examples of constructed, mathematical fractals of varying complexity. A whole category of fractals I would call “boring fractals” consists of patterns generated by a simple recursive substitution rule, expressed in a suitable formalism (such as L-systems). What they have in common is that they look exactly the same at all scales – there are no surprises. One simple example are tree-like images called fractal canopies, illustrating the perfect self-similarity inherent in an infinite recursive process.

Once understood and demystified, this kind of predictable fractal structure is in fact quite similar to a periodic pattern. Periodic patterns repeat along a spatial (or in rare cases, temporal direction), while simple fractals are constructed by repeatedly expanding a characteristic pattern “into itself” – thus the self-similarity – which is then visually reflected as similar details appearing on all scales[1]. A non-graphical example of the same phenomenon are fractal sequences generated by e.g. Toeplitz words and morphic words, and there is a well-understood connection between such discrete fractal-like infinite sequences and the intricate two dimensional fractal images many are familiar with. But however they are generated, I believe that in some way, ultimately all fractals are visual traces of some infinite recursion.

The really interesting fractals all seem to have deep connections to chaos. The typical examples in this category arise from studying (often quite simple-looking) dynamical systems, and the uncovered fractal images seem to exhibit intricacy and patterns that are neither obviously derivable from the dynamical system, nor appear reducible to a simple recursive substitution rule. Maybe, even quite certainly, this just shows our persisting lack of understanding of such processes. But this serendipitous emergence of unexpected complex patterns is what makes investigating such phenomena so enticing and exciting.

It is the realm of chaotic dynamical systems where we can discover a world of beautiful and organic-looking fractals that still harbor a lot of mysteries, while still being somewhat manageable and explainable using the tools of mathematical analysis. The most well-known fractal of this kind might be the Mandelbrot set.

From Dynamical Systems to Multibrot Sets

The Multibrot family of fractals is generated using a function $f_c: \mathbb{C} \to \mathbb{C}$ of the form

$$f_c(z) = z^d + c$$

where $c \in \mathbb{C}$ and $d \in \mathbb{Q}$. Fixing a value for $d$ defines a family of functions $f_c$. For each $c$ there exists a Julia set, and all the Julia sets are connected by a Multibrot set. At the end of this section it should be clear how they are defined and what their relation is.

The most studied case is $d=2$, defining the original Mandelbrot set, based on the quadratic family of functions $z^2 + c$ that plays a central role in the study of complex quadratic maps. The somewhat more general case of $d\in \mathbb{N}$ is partially covered by the study of complex rational maps. While, from a computational point of view, the fractional case (i.e. $d \in \mathbb{Q}\setminus\mathbb{N}$) is a natural and simple extension, note that the generalization to fractional powers is different from considering rational maps (i.e., functions $f$ such that $f = \frac{p(z)}{q(z)}$ where $p$ and $q$ are polynomials), so many theoretical results might not be directly applicable.[2]

Assume we fix some values for $d$ and $c$ and consider the function $f$ as a dynamical system of a single complex variable. For a given starting point $z_0$, what happens in the limit of infinite iteration, i.e. what can we say about the sequence of points $f^{(i)}(z_0)$ for $i \to \infty$, i.e. the orbit (or trajectory) of $z_0$ under repeated iteration of $f$? Some of the possible cases are:

  • it converges to a fixed value (fixed point)
  • it converges to a cycle (periodic point)
  • it never converges, but stays in a bounded region (limit set)
  • it diverges to infinity (i.e. the absolute value grows without bounds)

If for some $i>0$ we have a point $z$ with $f^{(i)}(z) = z$, then $z$ is called periodic, and if $i=1$ it is typically called a fixed point, because it is invariant under $f$. For $i>1$, the sequence of the points repeatedly visited along an $i$-periodic orbit forms a cycle. So fixed points are not actually a separate case, but are merely the simplest case of periodic points.

As another side note – sometimes functions are considered on the Riemann sphere $\hat{\mathbb{C}} := \mathbb{C} \cup \{\infty\}$, which is the complex plane extended in a natural way by a single additional point $\infty$ to denote the point at infinite distance in every direction. From this perspective, the “divergence to $\infty$” in the complex plane is elegantly replaced by having $\infty$ as just another fixed point, because by definition of the operations we always have $f(\infty) = \infty$. This, of course, affects certain statements that can be found concerning the number of fixed points, depending on the respectively used domain.

In certain cases, the orbit can asymptotically approach a limit set that is non-periodic, but still bounded (e.g. form a limit torus or a strange attractor), and the general case of a limit set also includes the chaotic case, i.e. points that have an “unpredictable”, aperiodic orbit, even if confined within some well-defined area.[3]

Now let us briefly think about the bigger picture – if we slightly move away from $z_0$ by some $\varepsilon>0$, how will this affect the orbit? If the orbits of $z_0$ and $z_0+\varepsilon$ are very close and asymptotically converge to the same limit set of points, it means that $z_0$ lies in the basin of attraction of some limit set (that can be a fixed point, periodic cycle or something else), which then is an attractor of the function. Conversely, if moving away from $z_0$ by a negligible amount drastically changes the resulting orbit, the limit set is repelling.

The Julia set $J(f)$ of a function $f$ can be defined as the closure of the set of repelling periodic points, while the Fatou set $F(f)$ is the complement and consists of one or more Fatou components, which are distinct regions with similar behavior. Those components can further be classified in 4 types.

In general, the repelling periodic points are just countably many (and thus vanishingly few) of the uncountable number of points in a Julia set – there is an uncountable number of points yielding aperiodic, chaotic orbits (see also here). Yet ironically, for all practical purposes, periodic points (discussed further in the next section) are the most tangible and only effectively computable part of these intricate sets.

For a fixed exponent $d$, the Multibrot set $\mathcal{M}_d$ is the set of values $c$ such that $J(f_c)$ is connected. To avoid discussing topology, for practical purposes it is sufficient to imagine that for these parameters of $c$, all the points in the corresponding Julia set form a connected area or curve in the complex plane, instead of being separated by points which are not in the set (like Cantor dust, in this case sometimes also called Fatou dust). For $d=2$, we get the famous Mandelbrot set. While this definition captures the most interesting property from a theoretical point of view, there are other provably equivalent definitions. One popular and very useful definition of a Multibrot set is

$$ \{c\in\mathbb{C} \mid |(f_c)^{(i)}(0)| \mathrm{\ for\ } i \in \mathbb{N} \mathrm{\ is\ bounded} \} $$

It means that $c$ belongs to the Mandelbrot set if iterating $f_c$ from the distinguished starting point 0 does not eventually diverge to $\infty$. The reason this works is because 0 is a critical point and in many cases the structure of a Julia set is related to the behavior of the underlying function on the critical points.[4]

If we identify each point $c$ in the complex plane with the function $f_c$ with the corresponding parameter, the Mandelbrot set can be understood as a map of Julia sets – it characterizes how variation of $c$ affects the resulting Julia sets based on the dynamics of the critical point 0. So for a fixed exponent $d$, the practical relation between the corresponding Julia and Multibrot sets is that

  • the Julia set is obtained by fixing the parameter $c$
    and considering orbits under $f_c$ for varying starting points $z_0$
  • the Mandelbrot is obtained by fixing the starting point ($z_0 := 0$)
    and considering orbits of $z_0$ under $f_c$ for varying parameters of $c$.

Basic Classification of Periodic Points

In this section, let $f$ be a function where we fixed $d$ and $c$. The $k$-periodic points of $f$ are the solutions of the equation $f^{(k)}(z) = z$, which cannot be solved symbolically in the general case, but can be numerically approximated. While the $2^k$ solutions (counted with multiplicity) can be computed, not every solution is guaranteed to be on the expected $k$-cycle, as for certain rare cases some periodic cycles are “missing” (these cases are summarized here, based on results from this paper).

Each $k$-cycle of points $p_1, …, p_k$ has a multiplier, $\lambda \in \mathbb{C}$ which is the same for all $p_i$ and is given by $(f^{(k)})^‘(p_i)$ for some point $p_i$, i.e. by evaluating the first derivative of the $k$-fold iterate of $f$ at point $p$. Using the chain rule, it can be shown that this is the same as the product of derivatives of $f$ along the cycle, i.e. $\prod_{i=1..k} f’(p_i)$. This massively simplifies the computation, because we only need to know and evaluate the first derivative in order to determine multipliers of any cycle.

Periodic cycles can be classified based on the multiplier:

  • $|\lambda|=0$: superattracting (also called critical)
  • $0 < |\lambda| < 1$: attracting
  • $|\lambda| = 1$: indifferent (or neutral)
  • $|\lambda| > 1$: repelling

Indifferent points where we have $\lambda = e^{2\pi i\cdot \alpha}$ with $\alpha \in \mathbb{Q}$ are called rationally indifferent (or parabolic). By definition, attracting points in the Fatou set and repelling points are in the Julia set. Furthermore, it can be shown that rationally indifferent points are also in the Julia set. For the remaining indifferent cases there exists deeper theory and classifications.

Note that for all functions of the shape $z^d + c$ (excluding $d=1$) we have one superattracting fixed point (i.e. critical point) at $0$ and another one at $\infty$.

Visualizing Julia and Mandelbrot Sets

A useful and important result about the Mandelbrot set is that it is bounded by a circle of radius 2 around the origin (this is also true for the respective Julia sets and some other Multibrot sets, for a proof see e.g. here or here). What this means is that for every starting point outside this circle, the orbit will definitely diverge to infinity (or in other words, the area outside the circle is in the basin of attraction of $\infty$).[5]

The Escape Time Algorithm

This allows for a very simple (but not very efficient) way to obtain a rendering of the Mandelbrot set – simply sample points $c\in\mathbb{C}$ in a region of the complex plane and count how many iterations of $f_c$ are needed until the absolute value is larger than 2, i.e. the orbit escapes the circle. As these orbits will diverge to infinity, we can abort the computation and conclude that these points are not in the set.

The radius of the circle is called escape radius and the number of iterations from a starting point until it is outside the circle is called escape time. As we can only determine with absolute certainty that a certain point is not in the set, and the points inside the Mandelbrot set will orbit inside of the circle forever, we need to set a limit on the number of iterations. For most purposes a value between 50 and 5000 is sufficient.

The basic form of the escape time algorithm can be summarized as follows.

  1. Pick an image size and a congruent rectangular region of $\mathbb{C}$ you want to depict.

You will need to directly or indirectly define a mapping from image pixel coordinates $(x,y)\in \mathbb{N}^2$ sample points $a+bi \in \mathbb{C}$, probably to a simple grid of points covering the target region using the same offset between adjacent points along both the real and imaginary axis.

  1. Compute the escape times by iterating the function $f_c$ on the sample points.

You can use the sample points

  • as the parameter $c$, to get the Multibrot set, or
  • as the starting point $z_0$, to get the Julia set.
  1. Define a color map assigning each escape time some color to produce an image.

The image pixels are simply colored according to the color assigned to the escape time for the underlying sample point. Two simple coloring schemes are

  • cycling through the colors (using the escape time, modulo number of colors), or
  • linearly interpolating between two colors for the range of distinct escape values.

The result will look like an onion with increasingly complex nested layers:

Mandelbrot set rendered using escape algorithm

In the image of the Mandelbrot set above, computed with a maximum escape time of 100, the dark blue color (on the left) corresponds to escape time 0 (i.e., points outside the circle), the increasingly bright areas correspond to the nested areas of points with increasing escape time. The Mandelbrot set is surrounded by the “white halo”, whereas the black areas in the middle are the points where the algorithm exceeded the maximum number of iterations. The true Mandelbrot set consists of points that will never turn white for any maximum escape value we would pick.

Escape Times and Lemniscates

Each colored area depicts a level set containing all points with the same escape time, and the boundaries between such sets are called lemniscates. These specific lemniscates are defined by polynomials derived from the equation $|f_c^{(i)}(z)| = 2$, i.e., asking for the points that land exactly on the escape boundary circle after exactly $i$ function iterations.

For our purposes, the polynomials are of no practical interest, because the equations quickly become unwieldy and finding solutions for arbitrary degrees is possible only using numerical methods anyway. Approximating the lemniscates using an (optimized) sampling-based approach is the practical way to go. In a theoretical sense though, one can see the lemniscates as a sequence of increasingly good approximations which in the limit converge to the Mandelbrot set. Note that there is nothing special about exactly these lemniscates – if we pick a different escape radius, their locations will shift.

However, some understanding of the lemniscates is useful for optimizing the escape time algorithm implementation. For example, one more efficient way of sampling points is to trace the lemniscates that bound a region with a fixed escape time, instead of sampling the whole area. Once we have determined the contours of two lemniscates, we know that all points in between have the same escape radius and can fill the complete area with the same color. This can drastically speed up computation in regions that are not “too close” to the complex boundary of the Mandelbrot set, but requires a more involved implementation for tracing a lemniscate curve and for filling the inside area with a color.

Of course there are also various tricks and other approaches of different degrees of sophistication for rendering the Mandelbrot set which are more efficient or use different techniques, such as doing inverse iteration or using the Lyapunov Exponent, which yields different or more aesthetic results.

Common Structures in the Mandelbrot Set

The Mandelbrot set has a number of visible structural patterns as well as more subtle properties. We will not go into a deeper discussion here, but this section aims at giving a high-level overview of common patterns and terminology. Most concepts apply to general Multibrot sets in a similar way.

The central black heart-shaped area of the Mandelbrot set is called the main cardioid, the approximately circular areas attached to it are called bulbs and the bolt-like lines going out from the bulbs are called antennae. Another prominent pattern are spirals, which emerge at certain Misiurewicz points which play a special role in the set.

Each cardioid or bulb corresponds to a region of parameters $c$ where the orbit (started at 0) will converge towards a cycle of some period and there are classifications of the bulb periods, see e.g. this paper or this summary of it. The pattern of bulb periods can be derived from the Farey tree. The points where bulbs are connected are bifurcation loci, i.e. points at the boundary of different dynamic behaviors. These points are flanked by external rays that come from infinity along a curved path into these points and are often used for the analysis of the fractals.

Apart from the omnipresence of bulbs, antennae and spirals at all scales, the Mandelbrot set in fact also exhibits a more direct form of self-similarity – it contains distorted copies, of itself, going by various names such as baby or mini mandelbrots.

The Mandelbrot set in the neighborhood of a parameter $c$ is known to look similar to the corresponding Julia set, which is not very surprising when considering the explained relationship between them and the fact that Julia sets for similar parameter values $c$ are also similar. Less apparently, the Mandelbrot set is also connected to the simpler real-valued logistic map – another well-studied chaotic dynamical system. More surprising connections exist to $\pi$ and the fibonacci numbers.

Further Resources

In addition to the links embedded in the text, I conclude this post with a list of various useful resources I stumbled on and have either already used or considered to be valuable to learn more about this rich and deep topic.

Complex Analysis

Complex Dynamical Systems

Fractals

Mandelbrot and Julia Sets

External Rays and Angles

Useful Software


  1. This intuitive similarity between scale and spatial dimension (which is also exploited for visualization, by mapping scale to e.g. depth) is actually an interesting topic of its own that I believe needs some deeper exploration.

  2. This should be obvious, but I am pointing this out because I initially failed to notice this, due to the fact that fractions are rational numbers. Unless I miss something, it looks to me that there is not much work concerning specifically fractional powers, results about “rational maps” must be critically checked in order to see if they might apply.

  3. Note that strange attractors (or repellers) are not necessarily chaotic – there is also research on and examples of strange non-chaotic attractors.

  4. One can, of course, still define and try to visualize sets analogous to Multibrot sets for starting points that are not 0, but will quickly find that the resulting sets will all look like distorted and somehow defective versions of the symmetrically looking set obtained the “proper” starting point 0. One natural special case is to consider picking $z_0 := c$. But this is effectively equivalent to starting with 0, as $f_c(0) = 0^d + c = c$ for any choice of $c$ and for $d\neq 0$.

  5. I will write a separate post on a possibly new observation I made concerning the escape radius, but for now the standard radius of 2 is all we need.