Tupper’s self-referential formula

A hideous equation that hides beautiful images, and much (much) more besides…


If you’re anything like me, then what I’m about to show you will have you checking the date isn’t April 1st. But no, that mischief-making time is far behind us, and the following is entirely true. Hold onto your logic hats, because we’re going to explore Tupper’s self-referential formula.

Meet the monster

$$\frac12 \lt \left\lfloor \operatorname{mod}\left( \left\lfloor \frac{y}{17}\right\rfloor 2^{-17\left\lfloor x\right\rfloor – \operatorname{mod}(\lfloor y\rfloor,17)}, 2\right)\right\rfloor$$

The Dr. Frankenstein behind this creature is the computer scientist, Jeff Tupper. In a 2001 paper on reliable, two-dimensional computer-graphing algorithms, Tupper introduced this as merely an example; this was just one function that could be plotted with graphing software. To plot this formula, we divide the $(x,y)$ plane into a grid of unit squares, as shown below:

The bottom-left square has value $(0,0)$ and then the one to the right has co-ordinates $(1,0)$, and so on. Essentially, we’re plotting on squares instead of points.

To plot the formula, we need to decide whether we’re going to shade a square or not. Given a square $(x,y)$, we calculate the value of the right-hand side of the inequality and colour the square black if the inequality holds. If the inequality doesn’t hold, we leave the square white. In Tupper’s formula, ‘mod’ refers to modular arithmetic — mod($a,b$) is the remainder when $a$ is divided by $b$. The other funny bit of the formula is the floor function. This is the half square bracket symbol, and returns the largest integer that is less than or equal to the input.

If you plot Tupper’s inequality over squares $0<x<105$, the outcoming is the following:

Image: Wikimedia commons user Larske, CC BY-SA 3.0

I’ll let that sink in for a moment. No, your eyes are not deceiving you — the formula plots a bitmap picture of itself! Hence the name Tupper’s self-referential formula, although Tupper never called it as such in his paper. You’re probably waiting for me to shout ‘April fools!’ but wait, it gets worse!

There is one slight missing detail, however. What is $k$ on the $y$-axis? We seem to be in comfortable terrain on the $x$-axis but in limbo on the $y$-axis. The value of $k$ is the following 543-digit number:

960 939 379 918 958 884 971 672 962 127 852 754 715 004 339 660 129 306 651 505 519 271 702 802 395 266 424 689 642 842 174 350 718 121 267 153 782 770 623 355 993 237 280 874 144 307 891 325 963 941 337 723 487 857 735 749 823 926 629 715 517 173 716 995 165 232 890 538 221 612 403 238 855 866 184 013 235 585 136 048 828 693 337 902 491 454 229 288 667 081 096 184 496 091 705 183 454 067 827 731 551 705 405 381 627 380 967 602 565 625 016 981 482 083 418 783 163 849 115 590 225 610 003 652 351 370 343 874 461 848 378 737 238 198 224 849 863 465 033 159 410 054 974 700 593 138 339 226 497 249 461 751 545 728 366 702 369 745 461 014 655 997 933 798 537 483 143 786 841 806 593 422 227 898 388 722 980 000 748 404 719

I completely lost it at this stage! If you look at the $k$th square on the $y$-axis up to $k+16$th square (providing you ignore everything below and above it), you will see the bitmap image of Tupper’s formula itself. It’s probably time to take an aspirin before you read on.

The plot thickens

In case you found the fact that Tupper’s formula plots an image of itself uninteresting, then let’s take it up a notch. Say we didn’t like our 543-digit $k$ value and wanted to scroll up and down the $y$-axis and see what we get. As you scroll up and down the axis from $-\infty < y < \infty$, Tupper’s formula plots everything.

Yes, everything!

Anything that you can imagine that fits in a 106 × 17 pixel grid is somewhere in the plot of the formula for different $k$-values. Here are some examples:

A bitmap image of Euler's identity, e^(i pi) + 1 = 0

Just beautiful.

Euler’s identity, found at the equally beautiful value of


The Gaussian integral: sqrt(pi) = integral of e^(-x^2) over the real line

The Gaussian integral formula, a beautiful equation but perhaps better displayed in a different font.

The Gaussian integral, with $k$ value


The chalkdust logo in bitmap form

A magazine for the mathematically curious.

A little something for Chalkdust… found at the ‘Chalkdust number’,


From picture to $k$

As previously explained, the plotting of this bitmap function takes place over a series of squares. However, say you had a picture in mind that you wanted to graph and needed to know its corresponding $k$-value. Rather than scrolling randomly until you find it, there is a much more efficient method:

  1. Beginning in the bottom left hand square of your desired image, allocate a 1 if you want it to be shaded in or a 0 if it should remain blank. Now consider the square directly above and assign either a 1 or 0 in the same way.
  2. Continue to scroll up the first column. Once the first column is dealt with, move onto the second column beginning with the bottom square again. Repeat the 1,0 allocating.
  3. Scroll up the second column, then the third, fourth, fifth and so on until you have assigned binary digits to each square in each column of the 106×17 pixel image.
  4. You will now have an incredibly long binary number (a 1802-digit number to be exact). Convert this number into base 10, and multiply by 17.
  5. Like magic, you now have your $k$-value.

To try Tupper’s formula for yourself, visit http://damnsoft.org/others/tupper.html and for more information, take a look at Numberphile’s video, The ‘Everything’ Formula.

Chalky comment: the author of this article, Harmeet Singh, published a similar piece last month with Plus Magazine, which is a favourite read of the Chalkdust team!

Harmeet is an A-level student from London. His A-levels include maths and further maths, alongside English literature. He is incredibly passionate about pure mathematics, particularly the Riemann Hypothesis and analysis. Harmeet hopes to complete a mathematics degree at Trinity College, Cambridge, leading onto a professorship and FRS, akin to his idols Ramanujan and GH Hardy.

More from Chalkdust