The stunning beauty of Chaos theory

Have you ever wondered what chaos theory is? If you give me a few minutes of your time, I will explain you the basics of one of my favorite fields in theoretical physics and what this beautiful title picture shows, only addition and multiplication required. Be ready to be amazed.

Fabio M. Graetz
9 min readSep 16, 2018

If you are interested in how to create the plots and animations I used in this article, look at this c++ program I wrote to create bifurcation diagrams.

In the early 60’s MIT professor Edward Lorenz worked on predicting the weather using the university’s new mainframe computers. He derived a simple set of equations that describe the convection of air and wrote a computer program to solve them. What he discovered next blew his mind: there was no randomness involved in the equations (deterministic system), yet he could run the computer program twice with the exact same parameters and get completely different results. Deterministic chaos was discovered.

In mathematics, computer science and physics, a deterministic system is a system in which no randomness is involved in the development of future states of the system. A deterministic model will thus always produce the same output from a given starting condition or initial state. (source)

So what had happened? Let’s look at the following example:

We pick a random number, for instance, 0.123267203462345822542 and in every step, we multiply it by 10 and remove the digit in front of the decimal point (which is equivalent to the operation mod 1)

Multiply it by 10 and you get:

1.23267203462345822542

Remove the digit in front of the decimal point (which is equivalent to the operation mod 1) and you get:

0.23267203462345822542

Now, we multiply it by 10 again:

2.3267203462345822542

And remove the number in front of the decimal point.

0.3267203462345822542

This is certainly a deterministic system because there is no randomness involved. Now, my question to you: can you predict the future of our number?

The answer is yes and no. For a few more steps, you can say exactly what the result will be. But what happens after 100 steps? I did not give you the number in the required accuracy!

A computer stores a certain number of digits after the decimal point (depending on the type you use). A 64-bit double has around 16 decimal digits of precision. So after applying our simple formula 15 times, you get unpredictable results. If you know how to code, I encourage you to try this for yourself! In early computers, equations like this one were even used as pseudo-random number generators.

Even if we knew 100 or 1000 digits after the decimal point, after 100 or 1000 steps, the result will be unpredictable because in our example information is destroyed every time we apply the operation mod 1 (delete the digit in front of the decimal point). The result, therefore, depends extremely critically on the initial condition.

Let’s summarize what we discussed until now:

Chaos theory is about equations or systems that are deterministic — meaning that there are clear instructions on how to calculate the future from the current state without any random elements involved — but that at the same time depend so critically on the initial conditions that it is impossible to predict the long-term future.

The title picture I chose for this article is a zoomed in region of the so-called bifurcation diagram of the logistic map (plot below). After reading the rest of this article, you will understand how to interpret this plot, one of my favorite ones from the entire field of physics :)

Bifurcation diagram of the logistic map

This is the equation of the logistic map. Don’t worry, we will look at it together.

The logistic equation describes a demographic model with two counteracting processes that govern the size of the population: reproduction vs starvation due to a limited food supply.

If there are no animals in the population x has a value of 0, and x=1 means that the population has reached its maximum size (due to limited food supply). r is the rate of reproduction.

The index i means population at time i, index i+1 means population at the next time step. This means that if in this model we know the rate of reproduction r and the current size of the population x_i, we can calculate the population at the next time step x_i+1.

Let’s look at an example to make it more clear. We assume r=1 (reproduction rate) for simplicity and for example a starting population of our animal herd of 80% of its maximum possible population (x_0 = 0.8).

This means that our animal herd shrank from 80% of the maximum possible population to 16% because the animals did not reproduce enough and there was not enough food to sustain a population of x = 0.8.

  • The 1 * 0.8 part describes the reproduction. The higher the reproduction rate (in this case 1), the higher the population in the next step. Here, the reproduction rate is 1, so in the next step, the result is still 0.8.
  • The (1–0.8) part describes the starvation since the term r * x_0 = 1 * 0.8 is multiplied by a factor of 0.2 which means that 4 out of 5 animals starved. The closer the population x is to 1, the more animals starve. Thank god, it is just a model ;)

Let’s take a look at how this development continues. The following plot shows the development of our herd over time. What happens? The population x tends to 0 which means that the animals did not reproduce enough and eventually died.

Let’s mark the result x=0 for a reproduction rate r=1 in the bifurcation diagram with a black point:

For reproduction rates between 0 and 1 the population dies

Let’s see what happens at larger reproduction rates for instance r=2.5:

The size of our herd quickly rises to around 60 percent of its maximum possible size and then stays constant. This is called a fixed point of the system. The fixed point does not depend on the initial value of x but only on the reproduction rate r. Let’s mark r=2.5 and x=0.6 in the bifurcation diagram with a green point:

We increase the reproduction rate to r=3.25. The following plot shows the development of the herd: You can see that the population starts oscillating between two population sizes! Why is this happening? At the larger population size there is not enough food for all the animals in our model, some of them die. Then there is enough food for the remaining animals. But once they reproduce again, there is not enough food for all of them and some die and so on and on…

The green fixed point splits into two, physicists say the period doubles. Let’s mark the two new fixed points of the system with blue points at r=3.25:

Can you guess what happens next, if we increase the reproduction rate any further? The two blue fixed points split into four. The size of the herd is now oscillating between four fixed sizes.

Let’s mark them in the bifurcation diagram:

What we are observing is called a period doubling cascade: the four fixed points become 8, 8 then 16, 32, 64 until infinity. At the end of the period doubling cascade, chaos starts. Instead of discrete fixed points that the population size can take or oscillate between, entire regions are marked in gray in the bifurcation diagram because the population takes all those values, the darker, the more often those values occur.

If you look at r=3.75 for example, the grey region starts at x around 0.25 and goes up to around 0.9, meaning that the population constantly varies between those values.

The plot below shows how our herd behaves for r=4: the population varies absolutely chaotically. If you would numerically calculate this development several times, you would find, that slightest variation in the initial population (for example due to limited numerical accuracy) yields dramatically different results over time, which is the main characteristic of chaos.

So far so good, but if you look closely at the chaotic region, you can see that within the gray, there are white stripes. What do they mean? Well, let’s take a closer look and zoom into the dashed rectangle!

That looks very similar to the previous plot, right? Let’s zoom in even further into the second rectangle.

What do you see? Left to r≈3.625 there is only chaos. The system can take all values marked in gray. Then, all of a sudden the chaos stops and a single fixed point emerges! These white regions are sometimes called islands of stability. Then the same thing happens again, the period doubles once, twice, …, period doubling cascade, onset of chaos.

If we would zoom in even further, we would find the same thing again: islands of stability within chaotic regions. Period doubling cascade, onset of chaos. Zooming in, more islands of stability and more period doubling cascades and more chaotic regions…

This absolutely blows my mind. It did the first time I learned about this and it still does years later. And all this complex chaotic behavior from such a simple model!

I tried to create an animation that shows this so-called self-similarity. While watching it, look at the flickering white islands of stability and the period doubling cascades found everywhere. Please switch to 1080p ;)

There are many other chaotic maps that show a similar behavior. I would like to show you one more example called Gauss map. It is sometimes also referred to as mouse map, can you guess why? ;)

We will not zoom into this one. The equation contains a second parameter, alpha, that is varied in the animation from 3.5 to 8.

Look out for period doubling when the curves split into two, four, eight,… You can observe period doubling cascades and also islands of stability emerging everywhere within the chaos.

I hope that I was able to teach you something and that you had fun reading this!

If you want to create diagrams or animations like these ones yourself, feel free to play with the code:

What the program does is actually not that complicated. A coordinate system is laid on top of the frame mapping every pixel to coordinates (r,x). For every column of pixels in the frame it first calculates the corresponding value of r. The program then calculates a sequence of values x according to the given chaotic map. A certain number of values is discarded (called transient) so that the system can reach its fixed points (if there are any). Then, the values x are binned into histograms, one for each column of pixels in the frame. The more x are in a bin, the darker the pixel will be. The frame is then written to a bitmap.

If you want to try this for yourself but have a hard time understanding parts of the code, write me, I’ll help you.

Now, with what you learned, I ask you to go back to the top and look at the title picture. Look at all the islands of stability within the chaos and all the period doubling cascades, isn’t this amazing?

--

--

Fabio M. Graetz
Fabio M. Graetz

Written by Fabio M. Graetz

Senior MLOps engineer at Recogni | Machine Learning | Kubernetes | Theoretical Astrophysicist | Bespoke Shoemaking | Berlin