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 R naturally.
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 gmp library within R.
## Load the library after installing GMP
library(gmp)
## Define the constant k
k = as.bigz("960939379918958884971672962127852754715004339660129306651505519271702802395266424689642842174350718121267153782770623355993237280874144307891325963941337723487857735749823926629715517173716995165232890538221612403238855866184013235585136048828693337902491454229288667081096184496091705183454067827731551705405381627380967602565625016981482083418783163849115590225610003652351370343874461848378737238198224849863465033159410054974700593138339226497249461751545728366702369745461014655997933798537483143786841806593422227898388722980000748404719")
## The tupper's formula
tupper = function(x, y, k){
z1 = as.bigz(y + k)
z2 = as.bigq(z1/17)
z3 = 2^(-17 * x - as.bigz(z1%%17))
0.5 < floor(as.bigz(z2 * z3)%%2)
}
## The x and y axis
x = 0:105
y = 0:16
## Compute the matrix
a = matrix(0, nc = length(x), nr = length(y))
for(i in seq_along(x)){
a[ ,107 - i] = rev(tupper(x[i], y, k = k))
}
Here is the plot
image(t(a), col = c("white", "black"))
No comments:
Post a Comment