Mathwords logoMathwords

Tupper's Self-Referential Formula — Definition, Formula & Example

Tupper's self-referential formula is an inequality in x and y whose graph, plotted in a thin strip of the plane, shows a picture of the formula itself. It works like a decoder. It reads the binary digits of a huge integer and turns each digit into a shaded or blank square.

Tupper's formula (Jeff Tupper, 2001) is the set of points satisfying the inequality below. Plot it over the region 0≤x<1060 \le x < 106 and k≤y<k+17k \le y < k + 17, where kk is a particular 543-digit multiple of 17. For integers xx and y=17n+ry = 17n + r with 0≤r<170 \le r < 17, the right-hand side equals bit number 17x+r17x + r in the binary expansion of nn. So each 1×11 \times 1 cell is shaded exactly when that bit is 1.

Key Formula

12<⌊mod⁡(⌊y17⌋2−17⌊x⌋−mod⁡(⌊y⌋, 17), 2)⌋\frac{1}{2} < \left\lfloor \operatorname{mod}\left( \left\lfloor \frac{y}{17} \right\rfloor 2^{-17\lfloor x \rfloor - \operatorname{mod}(\lfloor y \rfloor,\, 17)},\ 2 \right) \right\rfloor
Where:
  • xx = Horizontal coordinate. Its floor selects the column, from 0 to 105.
  • yy = Vertical coordinate, taken in the window from k to k + 17. The quotient by 17 gives the encoded number, and the remainder gives the row.
  • kk = The starting height of the 17-row window. It is a multiple of 17 that encodes the 106-by-17 bitmap.
  • ⌊⋅⌋\lfloor \cdot \rfloor = The floor function, which rounds down to the nearest integer.

How It Works

Write y=17n+ry = 17n + r. Then ⌊y/17⌋=n\lfloor y/17 \rfloor = n picks the number being decoded, and mod⁡(y,17)=r\operatorname{mod}(y, 17) = r picks the row. Multiplying nn by 2−(17x+r)2^{-(17x + r)} shifts its binary digits right by 17x+r17x + r places. Taking the floor of the result mod 2 then isolates a single bit. The inequality 12<bit\tfrac{1}{2} < \text{bit} is true only when that bit is 1. Each column xx therefore displays 17 consecutive bits of nn.

Worked Example

Problem: Use a toy window that starts at k = 221 instead of Tupper's 543-digit number. This window covers 221 ≤ y < 238. Decide whether the cells at (0, 223) and (0, 222) are shaded.
Step 1: Split y = 223 into a quotient and a remainder on division by 17. Since 17 × 13 = 221, the encoded number is n = 13 and the row is r = 2.
⌊22317⌋=13,mod⁡(223,17)=2\left\lfloor \tfrac{223}{17} \right\rfloor = 13, \qquad \operatorname{mod}(223, 17) = 2
Step 2: With x = 0 the exponent is −2. Shift 13 right by 2 places, reduce mod 2, and take the floor.
13⋅2−2=3.25,mod⁡(3.25,2)=1.25,⌊1.25⌋=113 \cdot 2^{-2} = 3.25, \quad \operatorname{mod}(3.25, 2) = 1.25, \quad \lfloor 1.25 \rfloor = 1
Step 3: Since 1/2 < 1, the cell (0, 223) is shaded. For y = 222 the row is r = 1. That gives 13/2 = 6.5, and mod(6.5, 2) = 0.5. The floor of 0.5 is 0, and 1/2 < 0 is false, so that cell is blank. This matches the binary form 13 = 1101, whose bit 2 is 1 and bit 1 is 0.
⌊mod⁡(13⋅2−1,2)⌋=⌊0.5⌋=0\left\lfloor \operatorname{mod}\left(13 \cdot 2^{-1}, 2\right) \right\rfloor = \lfloor 0.5 \rfloor = 0
Answer: (0, 223) is shaded and (0, 222) is blank. Column 0 shows the bits of 13 as shaded cells in rows 0, 2, and 3.

Why It Matters

Tupper built the formula to demonstrate his reliable graphing algorithm. That algorithm plots inequalities containing floor and mod exactly, cell by cell. The formula is also a compact lesson in bit extraction, the same shift-and-mask idea behind bitmap image formats and low-level programming.

Common Mistakes

Mistake: Believing the formula truly refers to itself, so that its graph is a picture of the formula everywhere in the plane.
Correction: The formula decodes any 106-by-17 bitmap. Every such picture appears in some window k ≤ y < k + 17. The self-portrait appears only for one specially chosen k. The real self-reference lives in that constant, not in the inequality.

Related Terms