public

Sierpinski Triangle

read-only

AI authored to showcase ironpad capabilities.

Sierpinski Triangle ▲

The Sierpinski triangle is a fractal that emerges from a surprisingly simple random process called the chaos game.

The Chaos Game

  1. Pick three vertices of an equilateral triangle
  2. Start at any point in the plane
  3. Repeat:
    • Randomly choose one of the three vertices
    • Move halfway toward that vertex
    • Plot your new position

Despite the randomness, the plotted points converge to a self-similar fractal, the Sierpinski triangle, with Hausdorff dimension \log 3 / \log 2 \approx 1.585.

[1]Chaos Game
1 panel
Saved output from the author's last run. Press Run to execute live in your browser.
Vec<(f64, f64)>, len = 50000, [(0.25, 0.14433756729740643), (0.625, 0.07216878364870322), (0.3125, 0.03608439182435161), (0.40625, 0.4510548978043951), (0.703125, 0.22552744890219756), (0.3515625, 0.11276372445109878), (0.67578125, 0.05638186222554939), (0.587890625, 0.461203633004994), (0.7939453125, 0.230601816502497), (0.89697265625, 0.1153009082512485), (0.448486328125, 0.05765045412562425), (0.7242431640625, 0.028825227062812125), (0.61212158203125, 0.44742531542362535), (0.306060791015625, 0.22371265771181267), (0.1530303955078125, 0.11185632885590634), (0.07651519775390625, 0.05592816442795317), (0.038257598876953125, 0.027964082213976584), (0.5191287994384766, 0.013982041106988292), (0.2595643997192383, 0.006991020553494146), (0.12978219985961914, 0.003495510276747073), ...]
[2]Render Fractal
1 panel
Saved output from the author's last run. Press Run to execute live in your browser.
(output too large to embed; run the cell to regenerate it)

Why Does Chaos Produce Order?

The chaos game works because of iterated function systems (IFS). Each "move halfway to a vertex" is a contraction mapping that shrinks the plane by a factor of \tfrac{1}{2}. The Sierpinski triangle is the unique attractor of these three contractions: regardless of the starting point, the orbit converges to the same fractal.

Variations to Try

  • Different ratios: Move \tfrac{1}{3} of the way instead of \tfrac{1}{2}. What happens?
  • More vertices: Use 4 vertices (square) with the constraint that you can't pick the same vertex twice in a row
  • Weighted randomness: Make one vertex more likely than the others, and the triangle becomes asymmetric

The chaos game reveals a deep connection between randomness and deterministic geometry: the fractal is encoded in the rules, not the randomness.