← All notes

How fast the butterfly forgets

Published · 3 min read

chaosdynamical systemsnumerics

The note on the Lorenz attractor ends with two trajectories that start a millimetre apart and end up on different wings. That is the qualitative picture of chaos. The quantitative one is a single number: how fast nearby trajectories separate.

For small separations the growth is exponential on average,

δ(t) ≈ δ₀ · e^(λ t)

and the rate λ is the largest Lyapunov exponent. A positive λ is the working definition of chaos. A periodic orbit has λ = 0; a system that settles to a fixed point has λ < 0.

Measuring it

The classic recipe, due to Benettin and co-workers in 1980, is almost embarrassingly direct. Run two copies of the system a tiny distance apart, measure how much the gap grew after one step, write the growth factor down, shrink the gap back to its original size along the same direction, and repeat. The average of the logarithms is λ.

import math

def lorenz(x, y, z, s=10.0, r=28.0, b=8/3):
    return s*(y - x), x*(r - z) - y, x*y - b*z

def rk4(p, h):
    k1 = lorenz(*p)
    k2 = lorenz(*(p[i] + h/2*k1[i] for i in range(3)))
    k3 = lorenz(*(p[i] + h/2*k2[i] for i in range(3)))
    k4 = lorenz(*(p[i] + h*k3[i] for i in range(3)))
    return tuple(p[i] + h/6*(k1[i] + 2*k2[i] + 2*k3[i] + k4[i]) for i in range(3))

h, d0, steps = 0.01, 1e-8, 200_000
a = (1.0, 1.0, 1.0)
for _ in range(5000):                 # let the transient die out
    a = rk4(a, h)
b = (a[0] + d0, a[1], a[2])
total = 0.0
for _ in range(steps):
    a, b = rk4(a, h), rk4(b, h)
    d = math.dist(a, b)
    total += math.log(d / d0)
    b = tuple(a[i] + (b[i] - a[i]) * d0 / d for i in range(3))   # renormalise

print(total / (steps * h))            # ≈ 0.906

Two thousand time units of integration give λ ≈ 0.906, in line with the value of 0.9056 found in the literature. The renormalisation is the important trick: without it the gap would grow until it reached the size of the attractor and saturate, and the logarithm would stop measuring anything.

What the number means

A rate of 0.906 means an error doubles every ln 2 / λ ≈ 0.77 time units. Turned around, it says how much a better measurement of the initial state is worth: each extra decimal digit of precision buys only ln 10 / λ ≈ 2.5 more time units of forecast. Starting with an error of 10⁻¹⁰ and calling the forecast useless once the error reaches the size of the attractor, about 10, the horizon is roughly 28 time units. Starting at 10⁻²⁰ would only push it to about 53.

That logarithm is the whole point Lorenz made in 1963. Predictability is bought with precision at an exponential price, so for a chaotic system there is a horizon that no realistic improvement in measurement will move very far.

The rest of the spectrum

A three-dimensional system has three Lyapunov exponents, one for each independent direction of stretching or squeezing. For Lorenz they are roughly

λ₁ ≈ +0.906    λ₂ = 0    λ₃ ≈ −14.57

The zero belongs to the direction along the flow: shifting a point forward along its own trajectory neither grows nor shrinks. The third one does not even need a separate computation. For the Lorenz equations the divergence of the vector field is constant, −(σ + 1 + β) ≈ −13.67, which means every volume in phase space shrinks by a factor e^(−13.67) per unit time, and the three exponents must add up to exactly that.

So trajectories are stretched apart in one direction and crushed together far more strongly in another. The Kaplan–Yorke estimate turns the spectrum into a dimension, 2 + λ₁ / |λ₃| ≈ 2.06: slightly more than a surface. That is why the attractor in the animation looks like a thin folded sheet with layers too fine to see.

A caveat about computers

After about thirty time units the computed trajectory has nothing to do with the exact one that starts from the same initial condition, because rounding errors are amplified like any other error. The exponent and the shape of the attractor are nonetheless robust: they are properties of the whole set, not of one path through it. Whether the strange attractor truly exists, rather than being an artefact of finite arithmetic, stayed open for decades; Warwick Tucker settled it in 1999 with a computer-assisted proof, answering the 14th of Smale’s problems for the century.

Also available in Français, Português