# Synchronizing Lorenz attractors I

Visualization, Math

Ever since I read James Gleick’s “Chaos: Making a New Science,”1 I have been obsessed with Lorenz attractors and chaotic systems in general. For a long time, I have wanted to find an excuse to visualize these behaviors extensively (there is such beauty in these systems!), but every time I kept just plotting a simple attractor, watching it for a couple of minutes, and moving to something else. However, some months ago, I came across the book “Sync: The Emerging Science of Spontaneous Order”2 by Steven Strogatz, and now I felt I had a great excuse!

# Lorenz equations

I cannot introduce Lorenz equations without including this great quote to set the context.

One day in the winter of 1961, wanting to examine one sequence at greater length, Lorenz took a shortcut. Instead of starting the whole run over, he started midway through. To give the machine its initial conditions, he typed the numbers straight from the earlier printout. Then he walked down the hall to get away from the noise and drink a cup of coffee. When he returned an hour later, he saw something unexpected, something that planted the seed for a new science.
(Gleick, 1987, p. 16)

Unknowingly, Edward Lorenz had missed a few decimals when giving the inputs to the computer (caused by a mismatch between the precision of his computer and his printer). What he accidentally discovered was that, for the set of equations he was using, tiny changes in initial conditions lead to hugely different outcomes. He later worked with a simplified system with only three equations. This new system would also end up showing incredible sensitivity to initial conditions. The equations were just three first-order differential equations, which seem surprisingly simple given the fact that they display such complex and chaotic behavior. These findings were the starting point of modern chaos theory.

The equations describe the movement through time of the variables $x$, $y$, and $z$, given some parameters $\sigma$, $\rho$, and $\beta$: \begin{align} \frac{dx}{dt} &= \sigma(y - x)\\ \frac{dy}{dt} &= x(\rho - z) - y\\ \frac{dz}{dt} &= xy - \beta z \end{align}

Using the parameters $\sigma=10$, $\rho=28$, and $\beta=8/3$, and plotting $x$ in the horizontal axis, $z$ in the vertical axis, and using $y$ as depth, we get our Lorenz attractor:

The behavior shown is truly chaotic. Even though the system is completely deterministic, without perfectly knowing the initial conditions, it is impossible to predict where the next point is going to be.

# Synchronizing attractors

Here is what I found most interesting: Despite the untamed behavior of the attractors, we can easily synchronize two (or more) Lorenz attractors! Here is Steven Strogatz’s description of the process:

Take two copies of a chaotic system. Treat one as the driver; in applications to communications, it will function as the transmitter. The other system receives signals from the driver, but does not send any back. The communication is one-way. […] By analogy with the Lorenz equations, their names are $x$, $y$, and $z$. Every night they perform onstage, playing off one another, each responding to the slightest cues of the other two. […] Now suppose that time stands still for a moment. The laws of the universe are suspended. In that terrifying instant, $x$ vanishes without a trace. In its place stands a new variable, called $x'$. It looks like $x$ but it is programmed to be oblivious to the local $y$ and $z$. Instead, its behavior is determined remotely by its interplay with $y'$ and $z'$, variables in a transmitter far away in another Lorenz system all part of an unseen driver. […] Soon all becomes right again. The $x$, $y$, $z$ trio glides in an utterly natural way, following through state space on the Lorenz attractor, the picture of chaotic grace. […] But what is so sinister here, and so eerie, is that $y$ and $z$ have now been turned into pods themselves. Unwittingly, they are now dancing in perfect sync with their own doppelgänger, $y'$ and $z'$, variables they have never encountered.
(Strogatz, 2003, pp. 196-197)

Translating what the quote is describing into equations, we get:

1. We have one “receiver” system, composed of $x$, $y$, and $z$: \begin{align} \frac{dx}{dt} &= \sigma(y - x)\\ \frac{dy}{dt} &= x(\rho - z) - y\\ \frac{dz}{dt} &= xy - \beta z \end{align}

2. We have one “driver” system, composed of $x'$, $y'$, and $z'$: \begin{align} \frac{dx’}{dt} &= \sigma(y’ - x’)\\ \frac{dy’}{dt} &= x’(\rho - z’) - y’\\ \frac{dz’}{dt} &= x’y’ - \beta z’ \end{align}

3. In the first system, we replace $x$ with $x'$. We forget about $x$ entirely: \begin{align} \frac{dy}{dt} &= x’(\rho - z) - y\\ \frac{dz}{dt} &= x’y - \beta z \end{align}

4. We keep updating $x'$, $y'$, and $z'$ according to the second system (the “driver”), and $y$, and $z$ according to the equations in point 3. The first system (the “receiver”) is now composed of $x'$, $y$, and $z$.

According to the quote, after a few iterations, we should see that the attractors start to synchronize. I wanted to visualize this by myself and play around with it, so I created a little script.

In the next demo, you can see two unsynchronized Lorenz attractors (the plot is showing $x$ on the horizontal axis and $z$ on the vertical axis). Just to show more easily the relationship between both, each new point generated in the first system (which is going to be the “driver”) is connected to the newest point generated in the second system (which is going to be the “receiver”).

When you click the demo, the script applies points 3 and 4 (from the list above). You will see that the line that joins them becomes vertical, showing that $x'$ now governs $x$. This makes the bottom attractor struggle to display its typical behavior (the classical “butterfly” shape), but after a few seconds, for each new point, $y$ starts to get closer to $y'$ and $z$ starts to get closer to $z'$, until they are—in Steven Strogatz’s words—dancing in perfect sync with their own doppelgänger.

→ I wrote a second part of this project here: Synchronizing Lorenz attractors II.

You can find all the code here .
You can also play with the code directly on a web editor: 3D attractor / Sync attractors.

1. Gleick, J. (1987). Chaos: Making a new science. New York, N.Y., U.S.A: Penguin.

2. Strogatz, S. (2003). Sync: The Emerging Science of Spontaneous Order. New York, N.Y., U.S.A: Hyperion Press.