## Tupper’s Self-Referential Formula

A couple of days ago I stumbled upon a rather old video post from Numberphile which talked about a formula that could plot itself, called the Tupper’s Self-Referential Formula:

At first it looked like magic; I even checked if the video was posted on April… and it was!
But apparently, it was the real thing.
So to understand how it works, I decided to create a small app that could evaluate the formula and plot it.

I soon realized that it wasn’t going to be easy, due to the huge values Tupper’s formula uses for the “y” axis. I mean, they are in the order of $10^{200}$!
These values are so large, because they actually represent the bits that are turned on and off in the image, encoded in a decimal value.

After trying some third party BigInteger classes, I discovered that .NET has been offering a native one for quite some time!

Once I implemented the native BigInteger structure from System.Numerics, the darn thing just worked.

This little program is very simple and doesn’t offer any user interface, although it contains several user-customizable options:

`Private scaleFactor As Integer = 10`

You can change this value to adjust the size of each pixel.

```Private tupperFormula As New TupperNumber("960...")
Private numberFile    As New TupperNumber("303...")
Private hello         As New TupperNumber("280...", True)
Private mattWasHere   As New TupperNumber("960...")
Private allBlack      As New TupperNumber("485...")
Private brilliant     As New TupperNumber("485...")
Private hi            As New TupperNumber("485...", True, True)
Private rickRoll      As New TupperNumber("148...")

Private n As TupperNumber = tupperFormula```

I have included several possible initial values for

`n`

. To test them, simply change the initialization value for any of the predefined

`TupperNumber`

entries.

Another interesting thing is the

`DirectBitmap`

class used in this project.
This class provides a very easy to manipulate bitmap while being considerably faster over the use of the standard Get/SetPixel methods. It is even faster than Locking/Unlocking the bitmap bits!
Thanks to SaxxonPike for making this code available.

Here’s a link to download a Visual Studio project file with the source code and a pre-compiled binary: