Lorenz Attractor

3D Chaotic Dynamics

The Lorenz system is a classic example of deterministic chaos:

\[ \begin{aligned} \dot x &= s (y - x), \\ \dot y &= r x - y - x z, \\ \dot z &= x y - b z. \end{aligned} \tag{1}\]

Figure 1: Lorenz attractor trajectory (Euler integration).

Implement the vector field

def lorenz(xyz, s=10, r=28, b=2.667):
    x, y, z = xyz
    x_dot = s * (y - x)
    y_dot = r * x - y - x * z
    z_dot = x * y - b * z
    return np.array([x_dot, y_dot, z_dot])

Simulate with Euler

num_steps = 10000
dt = 0.01
xyzs = np.empty((num_steps + 1, 3))
xyzs[0] = (0.0, 1.0, 1.05)

for i in range(num_steps):
    xyzs[i + 1] = xyzs[i] + lorenz(xyzs[i]) * dt

Try changing \(r\) or the initial condition and observe how the trajectory changes.

Reference code: amlab/extra/lorenz_attractor.py.