Series · ODE Foundations · Chapter 9

ODE Chapter 9: Chaos Theory and the Lorenz System

Deterministic yet unpredictable: the Lorenz system, butterfly effect, Lyapunov exponents, strange attractors, and the routes from order to chaos -- with Python simulations throughout.

In 1961, Edward Lorenz restarted a weather simulation from a rounded-off number – 0.506 instead of 0.506127. Within simulated weeks the forecast was unrecognisable. That single accident gave us the butterfly effect and turned chaos from a metaphor into a science. The lesson is profound and sober: equations that are exactly deterministic can still be practically unpredictable.

What You Will Learn

  • The four conditions that together define chaos
  • The Lorenz system: paradigm of deterministic chaos
  • Butterfly effect, visualised on the attractor itself
  • Lyapunov exponents: numerical fingerprint of chaos
  • Bifurcation cascades and the period-doubling route to chaos
  • Other chaotic systems: Rossler and the double pendulum
  • Strange attractors, fractal dimension, stretching-and-folding
  • Applications: weather, encryption, controlling chaos, ensemble forecasting

Prerequisites

  • Chapter 8: nonlinear systems, phase portraits, limit cycles
  • Chapter 7: stability and bifurcation basics
  • Comfort with 3D visualization

What Is Chaos?

A chaotic system satisfies all four of:

  1. Deterministic – governed by exact equations, no randomness
  2. Sensitive to initial conditions – tiny differences grow exponentially
  3. Bounded – trajectories stay in a finite region
  4. Aperiodic – they never repeat exactly
PropertyRandom ProcessChaotic System
EquationsContain noise termsCompletely deterministic
Short-term predictionStatistical onlyPrecisely predictable
Long-term predictionStatistical regularitiesCompletely unpredictable
Source of complexityExternal noiseIntrinsic dynamics

The deep insight: very simple equations can produce infinitely complex behaviour. Lorenz showed it with three.


The Lorenz System

Lorenz simplified atmospheric convection into three coupled ODEs:

$$\dot x = \sigma(y - x), \quad \dot y = x(\rho - z) - y, \quad \dot z = xy - \beta z$$
  • $x$: convection intensity
  • $y$: horizontal temperature difference
  • $z$: vertical temperature deviation
  • Classic parameters: $\sigma = 10,\ \rho = 28,\ \beta = 8/3$

The strange attractor

Lorenz attractor in 3D, two viewpoints, color-graded by time, showing the two wings.
Lorenz attractor at $\rho = 28$. Left: classic butterfly view. Right: top-down view, with the two equilibria $C_\pm$ (red X) at the centre of each wing. The trajectory weaves between the wings forever – never repeating, never escaping, never crossing itself.

Three signatures of “strangeness”:

  • Fractal structure. The Hausdorff dimension is $\approx 2.06$ – thicker than a surface, thinner than a volume.
  • Aperiodic. Infinite trajectory length confined to a finite volume.
  • No self-intersection. Uniqueness of ODE solutions forbids crossings at the same time.
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
import numpy as np
import matplotlib.pyplot as plt
from scipy.integrate import odeint

def lorenz(state, t, sigma=10, rho=28, beta=8/3):
    x, y, z = state
    return [sigma*(y-x), x*(rho-z)-y, x*y-beta*z]

t = np.linspace(0, 50, 10000)
sol = odeint(lorenz, [1, 1, 1], t)

fig = plt.figure(figsize=(10, 8))
ax = fig.add_subplot(111, projection='3d')
ax.plot(sol[:,0], sol[:,1], sol[:,2], lw=0.4, alpha=0.85)
ax.set(xlabel='X', ylabel='Y', zlabel='Z', title='Lorenz Attractor')
plt.tight_layout(); plt.show()

The Butterfly Effect, Visualised

Two trajectories that start a ten-billionth apart – $[1, 1, 1]$ and $[1 + 10^{-10}, 1, 1]$ – diverge exponentially until the difference is system-scale.

Butterfly effect: two close trajectories on the attractor; their x-components diverge; separation grows exponentially.
Top: two trajectories starting $10^{-8}$ apart, traced on the attractor (blue and red). Bottom-left: $x(t)$ for both – visually identical at first, then unrecognisable. Bottom-right: separation distance grows exponentially $\sim e^{\lambda t}$ until it saturates at the size of the attractor. The slope of the green dashed line is the largest Lyapunov exponent.

$$T_{\text{predict}} \;\approx\; \frac{1}{\lambda}\,\ln\!\frac{L}{\varepsilon_0}.$$

For the atmosphere $\lambda \approx 1/\text{day}$ and $\ln(L/\varepsilon_0) \approx 15$, giving $T \approx 15$ days. No improvement in models can push past this – only better measurements widen the gap inside the logarithm.

Ensemble view

A single trajectory tells you the worst case. An ensemble tells you the distribution.

Ensemble of 30 Lorenz trajectories starting within 1e-3 of (1,1,1); spread grows exponentially then saturates.
Top: 30 nearby starts produce orbits that are first indistinguishable, then mildly different, then totally incoherent. Bottom: the ensemble standard deviation grows exponentially through the green “predictable” regime and saturates in the red “incoherent” regime once it reaches system scale. This is exactly how operational weather centres quantify forecast confidence.


Lyapunov Exponents: Quantifying Chaos

$$\lambda_1 \;=\; \lim_{t\to\infty}\frac{1}{t}\,\ln\frac{|\delta\mathbf{x}(t)|}{|\delta\mathbf{x}(0)|}.$$
SignBehaviour
$\lambda_1 > 0$Chaos (exponential divergence)
$\lambda_1 = 0$Periodic or quasi-periodic
$\lambda_1 < 0$Asymptotically stable

For Lorenz at the canonical parameters, the spectrum is approximately $\{0.91,\ 0,\ -14.57\}$.

Largest Lyapunov exponent vs rho for Lorenz; bar chart of full spectrum at rho=28.
Left: numerically estimated $\lambda_1(\rho)$ – crosses zero into chaos around $\rho \approx 25$. Green dots are regular dynamics, red dots are chaotic. Right: full spectrum at $\rho = 28$. The sum is negative ($\sum \lambda_i = -13.66$), confirming volume contraction onto a fractal of Kaplan-Yorke dimension $\approx 2.062$.

Kaplan-Yorke (Lyapunov) dimension

$$D_{KY} \;=\; 2 + \frac{\lambda_1 + \lambda_2}{|\lambda_3|} \;\approx\; 2 + \frac{0.91}{14.57} \;\approx\; 2.062.$$

The attractor is almost a surface, but with infinitely many fractal layers stacked together.


Equilibria and the Route to Chaos

Setting $\dot x = \dot y = \dot z = 0$ gives three equilibria:

  • Origin $C_0 = (0,0,0)$ – stable for $\rho < 1$, saddle for $\rho > 1$
  • Symmetric pair $C_\pm = (\pm\sqrt{\beta(\rho-1)},\ \pm\sqrt{\beta(\rho-1)},\ \rho - 1)$ – born at $\rho = 1$
$\rho$Behaviour
$< 1$Origin globally stable
$= 1$Pitchfork bifurcation: $C_\pm$ appear
$1 < \rho < 24.74$$C_\pm$ are stable spirals
$\approx 24.74$Subcritical Hopf: $C_\pm$ lose stability
$24.74 < \rho < 28$Transient chaos, periodic windows
$\geq 28$Sustained chaos

The route from order to chaos shows up classically in the logistic map $x_{n+1} = r x_n (1 - x_n)$:

Logistic map bifurcation diagram (left) and zoom on the chaotic region (right).
Left: full cascade. Period 1 -> 2 -> 4 -> 8 -> … -> chaos at $r \approx 3.5699$. Right: zoom into the chaotic regime, exposing periodic windows (the prominent gap is the period-3 window at $r \approx 3.83$). The geometric ratio between successive doublings is the Feigenbaum constant $\delta \approx 4.6692$, and it is universal across one-dimensional unimodal maps.


Other Chaotic Systems

Rossler system

$$\dot x = -y - z, \qquad \dot y = x + a y, \qquad \dot z = b + z(x - c)$$

With $a = b = 0.2,\ c = 5.7$ this gives a “folded ribbon” attractor that exposes the stretching-and-folding mechanism more cleanly than Lorenz.

Double pendulum

Two hinged arms – one of the simplest mechanical systems with chaos.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
import numpy as np, matplotlib.pyplot as plt
from scipy.integrate import odeint

def double_pendulum(state, t, L1=1, L2=1, m1=1, m2=1, g=9.8):
    t1, w1, t2, w2 = state
    d = t2 - t1
    den1 = (m1+m2)*L1 - m2*L1*np.cos(d)**2
    den2 = (L2/L1)*den1
    dw1 = (m2*L1*w1**2*np.sin(d)*np.cos(d) + m2*g*np.sin(t2)*np.cos(d) +
           m2*L2*w2**2*np.sin(d) - (m1+m2)*g*np.sin(t1)) / den1
    dw2 = (-m2*L2*w2**2*np.sin(d)*np.cos(d) + (m1+m2)*g*np.sin(t1)*np.cos(d) -
           (m1+m2)*L1*w1**2*np.sin(d) - (m1+m2)*g*np.sin(t2)) / den2
    return [w1, dw1, w2, dw2]

t = np.linspace(0, 20, 2000)
sol1 = odeint(double_pendulum, [np.pi/2, 0, np.pi/2, 0],          t)
sol2 = odeint(double_pendulum, [np.pi/2 + 0.001, 0, np.pi/2, 0], t)
# ... plot endpoint trajectories and divergence

The double pendulum is the cleanest physical demonstration of chaos – you can build one on a table.


Strange Attractors: Stretching and Folding

Chaotic attractors have fractal structure – self-similar, with non-integer dimension. The mechanism is mechanical:

  • Stretch: nearby trajectories pulled apart -> sensitivity.
  • Fold: stretched material folded back -> boundedness.

Repeat infinitely and you get an infinitely layered “puff pastry”. Think of a baker kneading dough: stretch, fold, stretch, fold – after $n$ steps, two yeast cells initially $\varepsilon$ apart are $2^n \varepsilon$ apart along the layer direction.

That single mechanism – expansion in some directions, contraction in others, with global folding – is what every strange attractor in nature does.


Applications of Chaos

Weather prediction limits

  • 1-3 days: highly accurate
  • 3-10 days: useful reference
  • Beyond two weeks: only statistical trends

Modern centres use ensemble forecasting: run dozens of slightly perturbed initial conditions and report the spread.

Chaotic encryption

Two parties share the chaotic system parameters as a key. The unpredictability of the output makes it a stream cipher; without the key, the chaotic sequence cannot be reproduced.

Controlling chaos (OGY method, 1990)

  1. Locate unstable periodic orbits embedded in the chaotic attractor.
  2. When the trajectory naturally approaches such an orbit, apply tiny perturbations to keep it there.
  3. Chaos becomes periodic motion, suppressed with arbitrarily small control.

This has been used in laser physics, chemical reactors, and even cardiac pacing.

Chaos synchronisation

Two chaotic systems coupled strongly enough can synchronise on a common, still-chaotic trajectory – the mathematical basis of chaotic secure communications.


Chaos and Philosophy

Laplace’s demon (1814): “given perfect knowledge of every particle, the future is calculable.”

Chaos’s reply: even in a perfectly deterministic universe, the future is calculable only if measurements are infinitely precise. Errors grow exponentially, so any finite precision is forgotten in finite time.

This does not break causality. It limits predictability. The distinction matters.


Summary

ConceptKey Point
ChaosDeterministic + sensitive + bounded + aperiodic
Lorenz systemThe paradigm; butterfly attractor at $\rho=28$
Butterfly effect$10^{-10}$ initial difference -> system scale in $\sim 20$ time units
Lyapunov exponents$\lambda_1 > 0$ certifies chaos; magnitude sets prediction horizon
Bifurcation cascadePeriod-doubling $\to$ chaos with universal Feigenbaum ratio $\delta$
Strange attractorFractal dimension via Kaplan-Yorke formula
Forecast horizon$T \approx \lambda^{-1}\ln(L/\varepsilon_0)$
Ensemble forecastingStandard practice for chaotic systems

Exercises

Conceptual.

  1. What is the essential difference between chaos and randomness?
  2. Why are 2D continuous systems forbidden from chaos, while 3D ones permit it?
  3. What does a positive Lyapunov exponent mean physically and operationally?

Computational.

  1. Verify the origin of Lorenz is stable for $\rho < 1$ and a saddle for $\rho > 1$.
  2. Prove $\nabla\cdot\mathbf{f} = -(\sigma + 1 + \beta)$ – the Lorenz flow contracts phase-space volume at a constant rate.
  3. For the Cantor set, prove the box-counting dimension is $\ln 2/\ln 3$.

Programming.

  1. Plot the Lorenz attractor for $\rho \in \{10, 28, 100\}$ and compare topology.
  2. Compute the three Lyapunov exponents numerically; verify $\sum \lambda_i = -(\sigma + 1 + \beta)$.
  3. Animate the double pendulum from two nearly-identical starts; visually demonstrate divergence.
  4. Build the Rossler bifurcation diagram in $c$ and identify the period-doubling route.

References

  • Lorenz, “Deterministic Nonperiodic Flow,” J. Atmospheric Sciences (1963)
  • Strogatz, Nonlinear Dynamics and Chaos, CRC Press (2015)
  • Gleick, Chaos: Making a New Science, Viking Press (1987)
  • Ott, Chaos in Dynamical Systems, Cambridge (2002)
  • Ott, Grebogi & Yorke, “Controlling Chaos,” Physical Review Letters (1990)
  • Sparrow, The Lorenz Equations: Bifurcations, Chaos, and Strange Attractors, Springer (1982)

Series Navigation

Liked this piece?

Follow on GitHub for the next one — usually one a week.

GitHub