でたらめな跳躍が、なぜ完璧な三角形を描くのか
でたらめに選んだ頂点に向かって半分だけ跳ぶ。これを何度も繰り返します。純粋な偶然から、完璧なフラクタルが現れます。
クリックするとYouTubeから再生されます。
試してみよう:ルールを変える
純粋な偶然と、ひとつのルール:シェルピンスキーの三角形。半分の大きさの自分自身3つでできています。
なぜそうなるのか
三角形の3つの頂点からひとつをでたらめに選び、そこへ向かって半分だけ跳びます。その場所に印をつけて、繰り返します。跳躍は純粋な偶然なのに、数千回も跳ぶとシェルピンスキーの三角形が現れます。三角形から三角形をくり抜いた形が、あらゆる大きさで続く図形です。
xₖ₊₁ = xₖ + r · (頂点 − xₖ)三角形:r = 1/2五角形:r ≈ 0.618六角形:r = 2/3
自分で作る
Python 3 · numpy · matplotlib頂点へ半分だけ跳ぶでたらめな跳躍を60,000回。色は頂点で決まります。
"""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)
試してみよう: corners = 5 と r = 0.618 にするか、corners = 4 で no_repeat = True にしてみましょう。
このスクリプトを1行ずつ、練習問題とクイズで学ぶ → · Google Colabで実行(英語) →
先生向け: 45分の授業カードと3段階のワークシート →
動画が語る数学
動画の解説を読む(YouTubeより、英語)
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.
次の動画の説明より: The Chaos Game: Pure Randomness Draws a Perfect Fractal(英語).