---
title: "The Butterfly Effect · generative art"
description: "Two trajectories, one millionth apart. Generative art plate #19 by Theodore Vorillas, drawn live in your browser from its equations."
url: "https://vorillaz.com/lab/butterfly-effect"
---

![](https://vorillaz.com/_astro/butterfly-effect.rseRwZkH_Z8h8nJ.webp)

fig. #19 · rendered live in your browser from the equations below

# #19 the butterfly effect

Two trajectories, one millionth apart.

- date

  2026.09.28

- tags

  generative-art · javascript

> Does the flap of a butterfly’s wings in Brazil set off a tornado in Texas? — Edward Lorenz, 1972

Every attractor in this lab is fully deterministic: the same starting point always produces the same trajectory. Still, we call them chaotic, because of their sensitive dependence on initial conditions.

To make that visible, this experiment runs the classic Lorenz system twice. The second trajectory starts just `0.000001` away from the first. For a while the two lines overlap perfectly and look like one. Then, after a few loops, they split apart and end up on opposite wings of the butterfly, with nothing in common anymore.

## The algorithm

```javascript title="lorenz.js"
const sigma = 10;
const rho = 28;
const beta = 8 / 3;

const next = (x,y,z) => {
  const dx = sigma * (y - x);
  const dy = x * (rho - z) - y;
  const dz = x * y - beta * z;
  return {dx,dy,dz};
};
```

## Measuring the divergence

```javascript title="butterfly-effect.js"
const dt = 0.005;
let a = {x: 1, y: 1, z: 1};
let b = {x: 1 + 1e-6, y: 1, z: 1};

const step = (p) => {
  const {dx, dy, dz} = next(p.x, p.y, p.z);
  return {x: p.x + dx * dt, y: p.y + dy * dt, z: p.z + dz * dt};
};

const distance = (p, q) => Math.hypot(p.x - q.x, p.y - q.y, p.z - q.z);

for (let i = 0; i < 9000; i++) {
  a = step(a);
  b = step(b);
  // Grows roughly exponentially until it saturates at the size of the attractor
  plot(i, Math.log10(distance(a, b)));
}
```

The distance between the two points grows exponentially, at a rate set by the system’s largest Lyapunov exponent (about `0.9` for these parameters). On a log scale this shows up as a straight line climbing upwards until it flattens out at the size of the attractor itself.

## References

- [Deterministic Nonperiodic Flow](https://doi.org/10.1175/1520-0469\(1963\)020%3C0130:DNF%3E2.0.CO;2), Journal of the Atmospheric Sciences, 20(2), 1963.
- [Butterfly effect](https://en.wikipedia.org/wiki/Butterfly_effect)
- [Lorenz system](https://en.wikipedia.org/wiki/Lorenz_system)
