The Sierpinski Triangle
Two routes to the same triangle: a random walk that jumps toward a random vertex forever, or simply removing the middle triangle, recursively. The figure uses the second — true vector triangles, crisp at any zoom.
History
Wacław Sierpiński introduced this triangle in 1915 as an example of a curve that is simultaneously connected everywhere and has empty interior everywhere. Like Cantor’s dust, it began life as a counterexample in point-set topology, not as a picture to admire.
Construction: two routes to the same shape
Direct subdivision: remove the central inverted triangle, recurse into the three corners. The chaos game: pick any starting point, then repeatedly jump halfway toward a uniformly random vertex. Despite the randomness, the resulting cloud converges to exactly the same attractor:
where are the triangle’s three corners. Concretely, starting the chaos game from the origin with : jumping halfway toward lands at ; jumping halfway toward again from there lands at — each jump halves the remaining distance to whichever corner got picked, which is exactly what says algebraically.
Built from copies scaled by : .
Experiment: can randomness draw a perfect triangle?
The rule below never says “remove the middle triangle.” It knows only random vertex + halfway jump. Add a few points first; then a few hundred. Watch the apparent noise acquire forbidden regions and finally crystallise into the same Sierpinski triangle.
The surprise is easier to understand if we separate which map is chosen from what each map does. Every jump applies one of the same three contractions . Randomness changes the itinerary through those maps, but all sufficiently long itineraries are trapped near the unique IFS attractor. In that sense, chance chooses the route; contraction supplies the geometry.
The same triangle falls out of Pascal’s triangle: colour every odd binomial coefficient black, every even one white, and as the pattern converges to the Sierpinski triangle. Already unmistakable after just ten rows:
Ten rows of Pascal’s triangle; odd entries shaded solid, even entries left white.
Python implementation
Pseudocode first
sierpinski(a, b, c, depth) {
if (depth == 0) return {(a,b,c)}
ab = midpoint(a,b); bc = midpoint(b,c); ca = midpoint(c,a)
return recurse into (a,ab,ca), (ab,b,bc), (ca,bc,c)
}
The executable version keeps the recursive idea visible and delegates the polygon rendering to fractalfair_helpers.py.
from fractalfair_helpers import triangles_figure
def sierpinski(depth, a, b, c):
if depth == 0:
return [(a,b,c)]
ab, bc, ca = (a+b)/2, (b+c)/2, (c+a)/2
return (sierpinski(depth-1, a,ab,ca)
+ sierpinski(depth-1, ab,b,bc)
+ sierpinski(depth-1, ca,bc,c))
def draw(depth=7):
return triangles_figure(sierpinski(depth, *VERTICES))
sierpinskiRec :: Int -> P2 Double -> P2 Double -> P2 Double
-> [(P2 Double, P2 Double, P2 Double)]
sierpinskiRec 0 a b c = [(a, b, c)]
sierpinskiRec depth a b c =
concat [ sierpinskiRec (depth-1) a ab ca
, sierpinskiRec (depth-1) ab b bc
, sierpinskiRec (depth-1) ca bc c ]
where ab = mid a b; bc = mid b c; ca = mid c a
Figure: 2,187 filled triangles from seven levels of recursion, coloured by height from deep purple (bottom) to pale gold (apex).
Fractal geometry will make you see everything differently.
Sierpinski-triangle geometry shows up in fractal antenna design: the shape packs a long conducting path into a small footprint and resonates at multiple wavelengths, useful for compact multi-band mobile antennas.