Five places the Sierpiński triangle shows up

The Sierpiński triangle is a fractal that comes up in unexpected places. I’m not that interested in fractals, and yet I’ve mentioned the Sierpiński triangle many times on this blog just because I run into it while looking at something else.

The first time I wrote about the Sierpiński triangle was when it came up in the context of a simple random process called the chaos game.

Unbiased chaos game results

Next I ran into Sierpiński in the context of cellular automata, specifically Rule 90. A particular initial condition for this rule leads to the image below. With other initial conditions you don’t get such a clean Sierpiński triangle, but you do get similar variations on the theme.

Rule 90 with one initial bit set

Next I ran into Sierpiński in the context of low-level programming. The following lines of C code prints an asterisk when the bit-wise and of two numbers is non-zero.

    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++)
            printf("%c", (i&j) ? ' ' : '*');
        printf("\n");
    }

Then later I wrote a post looking at constructible n-gons, n-sided figures that can be constructed using only a straight edge and a compass. These only exist for special values of n. If you write these special values in binary, and replace the 1’s with a black square and the 0’s with a blank, you get yet another Sierpiński triangle.

Finally, if you look at the odd numbers in Pascal’s triangle, they also form a Sierpiński triangle.

4 thoughts on “Five places the Sierpiński triangle shows up

  1. Check out the ternary statement in the C code. I rewrote it in Python and confirmed my suspicion that the if and else statements should be reversed.

  2. I would argue that Rule 90 and Pascal’s triangle mod 2 should count as the same method, as Rule 90 is just addition modulo 2.

Comments are closed.