Visualizing Chaos: The Lorenz Attractor

Posted 3 months ago in Projects · Design · Code

Lorenz Attractor visualization

A Primer on Chaos Theory

Chaos theory studies how small changes in initial conditions can lead to vastly different outcomes - the famous “butterfly effect.” The Lorenz attractor, discovered by meteorologist Edward Lorenz in 1963, is one of the most iconic examples of this phenomenon. It’s a set of chaotic solutions to a simplified system of equations that model atmospheric convection.

What makes the Lorenz attractor fascinating is its “strange attractor” behavior - the system never repeats exactly the same path, yet it’s confined to a specific region in space, creating an intricate, butterfly-like pattern that’s both deterministic and unpredictable.

CodePen and Aesthetic Visualization

I created this visualization on CodePen, using P5.js to bring the mathematical concept to life. P5.js proved to be the perfect tool for this project - its simplicity and animation capabilities made it possible to create an interactive visualization with relatively few lines of code.

The result is a piece that captures both the mathematical beauty and the chaotic nature of the system. From there, I simply ported it to kohlhofer.com/lorenz. You can read more about that process in this post.

The Technical Side

The core of the visualization is surprisingly simple - just three differential equations:

dx/dt = σ(y - x)
dy/dt = x(ρ - z) - y
dz/dt = xy - βz

Where σ (sigma), ρ (rho), and β (beta) are parameters that determine the system’s behavior. The magic happens when we integrate these equations over time, plotting the resulting points in 3D space.

The Aesthetic Approach

While the mathematics behind the Lorenz attractor is fascinating, I wanted to create something fun. The visualization features smooth, flowing animations and dynamic camera movements that bring the mathematical concept to life. You can experience the full version at kohlhofer.com/lorenz, where you can watch the system evolve in real-time.

Part of a Larger Collection

This project lives in my “Bits & Pieces” collection at kohlhofer.com/bits - a playground where I dump my afternoon coding experiments and visual explorations. It’s where I try out new ideas, play with different technologies, and create things just for the fun of it. The Lorenz attractor is just one of many experiments where I mix code, design, and a bit of mathematical curiosity to create something visually interesting.

What’s Next?

The Lorenz attractor visualization serves as a perfect example of how mathematical concepts can be transformed into engaging visual experiences, making complex ideas more accessible and enjoyable to explore.

More posts

About this Site

I asked AI to tell me what Not So Common Thoughts is all about.