## Tupper’s self-referential formula

Tupper’s self-referential formula is a neat little math formula that when graphed over a certain (x, y) range will produce a graph that visually looks like the formula itself. To be specific, graphing the points (x, y-n) for all points that satisfy the inequality in the range of and where n is equal to:

9609393799189588849716729621278527547150043396601293066515

0551927170280239526642468964284217435071812126715378277062

3355993237280874144307891325963941337723487857735749823926

6297155171737169951652328905382216124032388558661840132355

8513604882869333790249145422928866708109618449609170518345

4067827731551705405381627380967602565625016981482083418783

1638491155902256100036523513703438744618483787372381982248

4986346503315941005497470059313833922649724946175154572836

6702369745461014655997933798537483143786841806593422227898

388722980000748404719

will result in the image:

While at first this sounds quite spectacular, it’s actually a bit of a trick: the formula itself is a general purpose method of graphing a monochromatic (two color) bitmap (specifically a bitmap that is 17 pixels in height). The range of y values start at a very large integer – an integer that is actually a representation of a bitmap of the formula.

I wrote a program using OCaml that can graph Tupper’s self-referential formula. I generalized it so that you can specify the integer-bitmap and the width and height of the image. I also wrote a Perl script that will convert an image into an integer representation of the image. The image doesn’t have to be monochromatic, but the Perl script will treat all non-black colors as if they are white. Only pure black is considered. The script requires the PerlMagick library. The Perl script expects the location of the image as a command line argument.

To compile the OCaml program on GNU/Linux (or other POSIX OS) you just need to run make. If that doesn’t work, or you are on a non-POSIX OS you can try to run:

ocamlopt -o tupper graphics.cmxa nums.cmxa tupper.ml

The program optionally takes three command line arguments – a value for n (the integer-bitmap), the width and the height. As it so happens, the Perl script will output those three values to the standard output meaning you can run the program like this:

./tupper `perl img_to_tupper.pl example.png`

Without any arguments it defaults to displaying the formula.