Happy Birthday!

 



Real-time refresh

Let the number above be k, plot the graph for in the range x = [0, 106) and y = [k, k+17), and you have your birthday wishes!

This is called Tupper’s self-referential formula. You may copy the original k that I put below to see why it is called a self-referntial formula. As a matter of fact, if you plot the graph for y = [0, ∞), you will get every 17 by 106 pixel map possible.

Some constants…

Tupper's Self-Referential Formula

4858450636189713423582095962494202044581400587983244549483093085061934704708809928450644769865524364849997247024915119110411605739177407856919754326571855442057210445735883681829823754139634338225199452191651284348332905131193199953502413758765239264874613394906870130562295813219481113685339535565290850023875092856892694555974281546386510730049106723058933586052544096664351265349363643957125565695936815184334857605266940161251266951421550539554519153785457525756590740540157929001765967965480064427829131488548259914721248506352686630476300

Happy Birthday

1822435620272423014151165695144465509683329639944655396124746378068598054593009808336588972215470050119838577255134178303473732516960276867260575622268200532498833052528561570268313422759208082834714968614919144595078902306824548232958432935148705648980243415472696531371321848505608618542052469913945411625116269008797192168692573727293131493913126401119493162537756238118480020151082684105427938569277618846103430647050135480533260921487964017511315990359396772940432707412568137384195194153168531415075362397205439165268667980049087887048704

How it works

Actually, the plotting code doesn’t really evaluate that inequality. Since and are real numbers, it is impossible for computers to plot the graph directly. (There are workarounds though, read till the end.) However, firstly we can observe that and are floored so that you may choose and as integers, reducing the computation to 1926 times.

Still, this doesn’t explain why this formula maps a pixel map to an integer. We should look into the formula’s true intention.

Step 1: Simplify the formula

${1 \over 2} < {\lfloor x \rfloor}$ is the same as $1 <= {\lfloor x \rfloor}$ since the floor function returns only integers.

Let $y=17m+n$ so that we can simplify $\lfloor {y \over 17} \rfloor$ as $m$, rewrite the formula as

Step 2: Get the idea

  1. If we take a binary number $b$, divide it by $2^e$, we basically moved $b$ to the right by $e$ bits. (See Bitwise Operation)

  2. If we take a binary number $b$, mod it by $k$, we obtain its rightmost digit, which is either 0 or 1 by the definition of binary representation.

Observe $\mathrm{mod} \left(\frac{m}{2^{17x+n}}, 2 \right)$, based on the two conclusions above, it is equivalent to retrieving the $(17x+n)^{th}$ bit of $m$ (counting from the rightmost digit).

Step 3: Conclude

Then the formula means the $(17x+n)^{th}$ bit of $m$ is 1 (binary digits can only be 0 or 1). If we want to make $(x,n)$ a black pixel in the graph, we put a 1 on the $(17x+n)^{th}$ bit of $m$, do the same thing for all combinations of $(x,n)$ to come up with an $m$.

In human language Draw a grid of 18*107, read vertically from bottom to top, from left to right. If you meet a black pixel, put a 1 to the left of your number, otherwise put a 0.

The $K$ that you want is $m * 17$. (Why?)

Hint How do we define $m$? If $i$ is a multiple of 17, does $j \in [0, 17)$ change the value of $\lfloor{ {i+j} \over 17 }\rfloor$?

This is the original paper Reliable Two-Dimensional Graphing Methods for Mathematical Formulae with Two Free Variables written by Jeff Tupper. He proposed this formula to validate a plotting technique to handle flooring and ceiling operations in functions. You may check it out.

Making of this post

This post is made possible with the help these resources:

Tupper’s Formula Tools: helped me understand how the formula works, and how to plot it with respect to K.

MathJax: use this to render beautiful math expressions on any browser.

Confetti.js: made the confetti effect on the top^^