← 🌀 Chaos & Dynamics
🌀 Chaos • Difficulty ★★☆

Lorenz Attractor — 3D Butterfly Effect Visualisation

Explore the famous Lorenz strange attractor in 3D. Two trajectories starting infinitesimally apart diverge exponentially — the butterfly effect. Adjust σ, ρ, β parameters and discover bifurcations. Drag to rotate.

● Trajectory 1
● Trajectory 2
σ=10 ρ=28 β=2.67

🌀 Lorenz Controls

Presets:
Position (x,y,z):
Trajectory Divergence:
Est. Lyapunov λ₁:

Lorenz Equations

dx/dt = σ(y−x); dy/dt = x(ρ−z)−y; dz/dt = xy−βz. Classic parameters: σ=10, ρ=28, β=8/3. The Lorenz attractor has a fractal dimension D≈2.06 and positive Lyapunov exponent λ₁≈0.906, confirming chaotic behaviour. Trajectories never repeat yet stay within a bounded region of phase space.

Butterfly Effect

Two trajectories starting ε=10⁻⁵ apart diverge exponentially: |δ(t)| ≈ |δ₀|·e^(λ₁t). With λ₁≈0.9, predictability horizon T_pred ≈ (1/λ₁)·ln(1/ε) ≈ 13 time units. In atmospheric modelling (where Lorenz discovered this), this limits weather forecasting to ~2 weeks regardless of how accurate the initial measurements are.

Bifurcations & Regimes

For ρ < 1: stable origin (all trajectories → 0). For 1 < ρ < 24.74: two stable fixed points (C⁺ and C⁻). At ρ=24.74: period-doubling bifurcation cascade begins. For ρ > 24.74: chaotic strange attractor. At ρ≈99.96: a periodic window within chaos. Drag the ρ slider to explore these regimes.

About this simulation

This simulation numerically integrates the Lorenz system, dx/dt = σ(y−x), dy/dt = x(ρ−z)−y, dz/dt = xy−βz, using fourth-order Runge–Kutta (RK4) with a fixed step of dt = 0.005. Two trajectories are advanced in parallel from nearly identical starting points — (0.1, 0, 0) and (0.1+ε, ε, 0) — so you can watch them separate. Every animation frame runs 5 RK4 sub-steps and, whenever the two trajectories drift closer than 10⁻³ apart, the code measures their separation, accumulates it into a running Lyapunov-exponent estimate, then renormalises trajectory 2 back to distance ε from trajectory 1. The 3D view is a simple perspective projection with mouse-drag rotation and scroll-to-zoom, centred on the attractor's mean height (z−25).

🔬 What it shows

Two point masses evolve under identical Lorenz equations from almost-identical initial conditions. Trajectory 1 (pink) and Trajectory 2 (blue) trace out the classic butterfly-shaped strange attractor, weaving between two lobes without ever exactly repeating. The live readouts show each point's (x, y, z) position, the current distance between the two trajectories, and an estimated largest Lyapunov exponent λ₁ computed from how fast that distance grows between renormalisations.

🎮 How to use

Drag σ (sigma), ρ (rho) and β (beta) to change the equations' parameters — the default classic values are σ=10, ρ=28, β=8/3 (≈2.67). Initial Separation ε sets how close the two starting points are (as a multiple of 10⁻⁵), and Trail Length controls how many recent points are drawn. Click Pause/Run to freeze or resume integration, Reset to restart both trajectories from scratch, and +Trajectory to respawn trajectory 2 next to trajectory 1's current position. Drag the canvas to rotate the view and scroll to zoom; the four preset buttons jump straight to Classic Chaos, Near Bifurcation (ρ=24), Periodic (ρ=99.96) and Transient Chaos.

💡 Did you know?

Edward Lorenz discovered this system in 1963 while re-running a weather model with a rounded-off initial value — the tiny truncation produced a wildly different forecast, which he later described as the "butterfly effect." At the classic parameters (σ=10, ρ=28, β=8/3) the attractor has a fractal (non-integer) dimension of roughly 2.06, meaning it is more than a 2D surface but less than a solid 3D volume.

Frequently asked questions

What do σ, ρ and β control in the Lorenz equations?

σ (sigma) is the Prandtl number, controlling how quickly the x variable responds to differences with y; ρ (rho) is the (rescaled) Rayleigh number, driving the system's overall energy and, past a threshold, its chaotic behaviour; β (beta) is a geometric factor related to the physical box the original convection model represented. The simulation's default values, σ=10, ρ=28, β=8/3, are the exact parameters Edward Lorenz used in his 1963 paper, which is why they are labelled the "Classic Chaos" preset.

How is the trajectory actually computed — is it exact?

The simulation integrates the three coupled differential equations numerically with the classic fourth-order Runge–Kutta method (RK4) at a fixed timestep of dt = 0.005, advancing each trajectory by 5 sub-steps per rendered frame. RK4 is far more accurate than a simple Euler step for a given timestep, but it is still an approximation: like any numerical integrator applied to a chaotic system, tiny discretisation errors eventually grow exponentially, which is itself a demonstration of the sensitivity the simulation is illustrating.

Why are there two trajectories, and what is the Lyapunov exponent?

Trajectory 2 starts at a distance ε from Trajectory 1 (ε defaults to 5×10⁻⁵, adjustable via the Initial Separation slider). Because the Lorenz system is chaotic, this minuscule initial gap grows exponentially over time — the "butterfly effect." Whenever the two points come back within 10⁻³ of each other, the code measures the actual growth in separation since the last renormalisation, adds it to a running sum, and renormalises trajectory 2 to distance ε again; dividing the running average by dt gives the live estimate of the largest Lyapunov exponent λ₁ shown in the stats.

What happens if I change ρ (rho)?

Lowering ρ moves the system out of chaos: below ρ≈24.74 the two lobes' fixed points become stable again and trajectories spiral into one of them rather than wandering forever, which is what the "Near Bifurcation (ρ=24)" preset demonstrates. Raising ρ to specific values can produce periodic windows inside otherwise chaotic behaviour — the "Periodic (ρ=99.96)" preset lands on one such window where the trajectory settles into a repeating loop instead of chaotic wandering.

Why does the shape look like a butterfly?

The Lorenz attractor has two "wings" corresponding to two unstable fixed points of the equations. A trajectory circles around one wing for a while, then unpredictably crosses over and circles the other, producing the two-lobed, butterfly-like silhouette. Because the switching between wings depends sensitively on the exact trajectory, no two runs (or even the two trajectories rendered side by side here) trace exactly the same path, even though both stay confined to the same overall butterfly-shaped attractor.