Pourquoi des sauts au hasard dessinent un triangle parfait
Saute à mi-chemin vers un sommet tiré au hasard, encore et encore. Une fractale parfaite naît du pur hasard.
Lecture depuis YouTube après un clic.
Essaie : change la règle
Le pur hasard, une seule règle : le triangle de Sierpiński, trois copies de lui-même deux fois plus petites.
Pourquoi ça marche
Choisis au hasard un des trois sommets d’un triangle et saute à mi-chemin vers lui. Marque le point et recommence. Les sauts sont du pur hasard, et pourtant, après quelques milliers, le triangle de Sierpiński apparaît : un triangle évidé de triangles, à toutes les échelles.
xₖ₊₁ = xₖ + r · (sommet − xₖ)triangle : r = 1/2pentagone : r ≈ 0,618hexagone : r = 2/3
Construis-le toi-même
Python 3 · numpy · matplotlib60 000 sauts au hasard à mi-chemin vers un sommet, colorés selon le sommet.
"""Chaos game: jump a part r of the way to a random corner of a polygon, again and again.
Run: python chaos-game.py (needs: pip install numpy matplotlib)
"""
import numpy as np
import matplotlib.pyplot as plt
plt.style.use("dark_background")
corners, r, no_repeat = 3, 0.5, False # triangle, halfway: the Sierpinski triangle
steps = 60000
rng = np.random.default_rng()
angles = np.pi / 2 + 2 * np.pi * np.arange(corners) / corners
vertex = np.column_stack([np.cos(angles), np.sin(angles)])
points, chosen = np.zeros((steps, 2)), np.zeros(steps, dtype=int)
x, last = np.array([0.0, 0.0]), -1
for i in range(steps):
c = rng.integers(corners)
while no_repeat and c == last: # the restricted game: never the same corner twice
c = rng.integers(corners)
x = x + r * (vertex[c] - x) # the whole rule
points[i], chosen[i], last = x, c, c
plt.figure(figsize=(6, 6))
plt.scatter(points[20:, 0], points[20:, 1], s=0.3, c=chosen[20:], cmap="rainbow")
plt.axis("equal")
plt.axis("off")
plt.show()
# Try: corners, r = 5, 0.618 (a pentagon) or corners, no_repeat = 4, True (a square, restricted)
Essaie : Mets corners = 5 et r = 0.618, ou corners = 4 avec no_repeat = True.
Apprends ce script ligne par ligne, avec des exercices et un quiz → · lance-le dans Google Colab (en anglais) →
Pour les enseignants : une fiche de cours de 45 minutes et une fiche d’exercices sur trois niveaux →
Les maths, telles que le film les raconte
Lire les notes du film (de YouTube, en anglais)
Start anywhere. Pick one of the triangle's three corners at random and jump exactly halfway toward it. Plot the point.
Repeat. Nothing about the choices is planned — a coin, a die, pure chance — and yet after a few thousand jumps the Sierpiński triangle appears, sharp and complete. The reason is that "jump halfway to a corner" is a contraction: it shrinks every distance by half, so wherever the point starts, after a handful of jumps it is pulled onto the one shape that the three half-size copies of itself map back onto — the fractal is the only set the rule leaves unchanged.
Each point here is coloured by the corner it just jumped toward, which is why order seems to grow out of rainbow noise. From the triangle on, only the rule changes: a pentagon with a golden jump of 0.618, a pentagon where the same corner may never be chosen twice in a row, a square where the opposite corner is forbidden, a hexagon with a two-thirds jump. Every new shape is born from the cloud of the previous one, because the walkers simply keep going under the new rule.
Nothing is drawn; everything is counted.
D’après la description de Pure Randomness Draws a Perfect Fractal (en anglais).