Lesson 2 of 15

Lorenz Attractor

Lorenz Attractor

In 1963, Edward Lorenz discovered that a simplified model of atmospheric convection produces strikingly complex, non-repeating trajectories — the first famous example of a strange attractor.

The Lorenz System

dxdt=σ(yx)\frac{dx}{dt} = \sigma(y - x) dydt=x(ρz)y\frac{dy}{dt} = x(\rho - z) - y dzdt=xyβz\frac{dz}{dt} = xy - \beta z

Classic parameters: σ=10\sigma = 10, ρ=28\rho = 28, β=8/3\beta = 8/3

The state vector (x,y,z)(x, y, z) evolves continuously. With these parameters the system is chaotic, with a Lyapunov exponent of approximately 0.90.9.

Numerical Integration: RK4

We integrate using the fourth-order Runge-Kutta (RK4) method with time step dt=0.01dt = 0.01:

k1=f(s)k2=f ⁣(s+dt2k1)k3=f ⁣(s+dt2k2)k4=f(s+dtk3)k_1 = f(s) \quad k_2 = f\!\left(s + \tfrac{dt}{2}k_1\right) \quad k_3 = f\!\left(s + \tfrac{dt}{2}k_2\right) \quad k_4 = f(s + dt\,k_3)

sn+1=sn+dt6(k1+2k2+2k3+k4)s_{n+1} = s_n + \frac{dt}{6}(k_1 + 2k_2 + 2k_3 + k_4)

Key Properties

  • Sensitivity to initial conditions: two trajectories starting 101010^{-10} apart diverge exponentially.
  • Strange attractor: trajectories are bounded but never repeat — they lie on a fractal set with dimension 2.06\approx 2.06.
  • Butterfly shape: the attractor has two lobes around the two unstable fixed points at (±β(ρ1),±β(ρ1),ρ1)(\pm\sqrt{\beta(\rho-1)}, \pm\sqrt{\beta(\rho-1)}, \rho-1).

Your Task

Implement:

  • lorenz_deriv(state, sigma=10, rho=28, beta=8/3) — returns (dx,dy,dz)(dx, dy, dz) as a tuple
  • lorenz_rk4_step(state, sigma=10, rho=28, beta=8/3, dt=0.01) — one RK4 step, returns new (x,y,z)(x, y, z)
  • lorenz_trajectory(x0, y0, z0, n_steps=1000, dt=0.01) — returns list of (x,y,z)(x,y,z) tuples (including initial state)
Python runtime loading...
Loading...
Click "Run" to execute your code.