· Math

Tupper’s Self-Referential Formula

Tupper’s self-referential formula is a single inequality that, when graphed over a specific rectangle in the plane, can display a bitmap image that is encoded inside one very large integer.

The formula

12<mod ⁣(y17217xmod(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

When the left side is true at a point (x,y)(x,y), you color that point (or pixel) black; otherwise, white.

How it works

  • The plot is typically restricted to a 106×17106 \times 17 rectangle:

    • x[0,106)x \in [0,106) (106 columns)
    • y[k,k+17)y \in [k, k+17) for a special integer offset kk (17 rows)
  • The integer

    k=y17k = \left\lfloor \frac{y}{17} \right\rfloor

    acts like a huge “data register”. It contains the entire 106×17 bitmap, packed as bits in its binary expansion.

  • The term

    17x+mod(y,17)17\lfloor x \rfloor + \operatorname{mod}(\lfloor y \rfloor, 17)

    computes a bit index:

    • x\lfloor x \rfloor picks the column (0 to 105)
    • mod(y,17)\operatorname{mod}(\lfloor y \rfloor,17) picks the row (0 to 16)
    • Multiplying by 17 means each column consumes 17 bits (one per row)
  • The factor

    2(17x+mod(y,17))2^{-\,\big(17\lfloor x \rfloor + \operatorname{mod}(\lfloor y \rfloor,17)\big)}

    shifts the binary representation of kk right by that bit index (in a real-number sense).

  • Then

    mod(,2)\operatorname{mod}(\cdot, 2)

    extracts whether the least significant bit is 0 or 1 after shifting.

  • Finally, the outer floor and the comparison

    12<\frac{1}{2} < \lfloor \cdot \rfloor

    turn that extracted value into a clean boolean decision for coloring.

The “self-referential” part

If you choose kk to be the integer whose packed bits correspond to the image of the formula itself, then plotting the inequality over x[0,106)x \in [0,106) and y[k,k+17)y \in [k,k+17) produces that same image. The formula can draw a picture that encodes the formula.

Practical note

The value of kk for the famous self-plot is astronomically large (thousands of digits). In code, you usually render it by:

  1. treating the 106×17 region as a pixel grid, and
  2. extracting bits from a big integer (often using BigInt), instead of evaluating the real-valued inequality point-by-point.

Example Plot

This bitmap behavior can be visualized as follows: Note that when the two plots are added together, the values get carried over due to binary addition rules, resulting in the original image being distorted by the overlay. image

Topics

  • Math
  • Visualization