Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Can't remember where I first came across this equation but the Tupper's self referential equation, is a very interesting formula that when graphed in two dimension plane it reproduces the formula.

$\frac{1}{2} < \left\lfloor \bmod\left(\left\lfloor\frac{y}{17}\right\rfloor2^{-17\lfloor x\rfloor - \bmod(\lfloor y \rfloor, 17)}, 2\right)\right\rfloor$

I first thought this would be a quick 5 min exercise which turned into a 3 hour work, the obstacle was that the constant “k” used in the formula is an extremely big integer and can not be handled in Rnaturally.

After a little search Large integer in R and play around it seems that the gmp library seems to work well.

First you will need to install GMP (The GNU Multiple Precision Arithmetic Library) from http://gmplib.org/, then install the gmplibrary within R.

## Load the library after installing GMP<br />library(gmp)<br /><br />## Define the constant k<br />k = as.bigz("960939379918958884971672962127852754715004339660129306651505519271702802395266424689642842174350718121267153782770623355993237280874144307891325963941337723487857735749823926629715517173716995165232890538221612403238855866184013235585136048828693337902491454229288667081096184496091705183454067827731551705405381627380967602565625016981482083418783163849115590225610003652351370343874461848378737238198224849863465033159410054974700593138339226497249461751545728366702369745461014655997933798537483143786841806593422227898388722980000748404719")<br /><br />## The tupper's formula<br />tupper = function(x, y, k){<br />  z1 = as.bigz(y + k)<br />  z2 = as.bigq(z1/17)<br />  z3 = 2^(-17 * x - as.bigz(z1%%17))<br />  0.5 < floor(as.bigz(z2 * z3)%%2)<br />}<br /><br />## The x and y axis<br />x = 0:105<br />y = 0:16<br /><br />## Compute the matrix<br />a = matrix(0, nc = length(x), nr = length(y))<br />for(i in seq_along(x)){<br />  a[ ,107 - i] = rev(tupper(x[i], y, k = k))<br />}<br />

Here is the plot

image(t(a), col = c("white", "black"))<br /> 