#!/usr/bin/env python # coding: utf-8 # In[4]: from mpmath import mp import numpy as np import matplotlib.pyplot as plt get_ipython().run_line_magic('pylab', 'inline') # [Tupper's formula](https://en.wikipedia.org/wiki/Tupper%27s_self-referential_formula) # # $$\frac{1}{2} < \left \lfloor{ \text{mod}\left ( \left \lfloor{\frac{y}{17}} \right \rfloor 2^{-17 \lfloor{x}\rfloor - \text{mod} \left ( \lfloor{y}\rfloor, 17 \right )} \right ) } \right \rfloor$$ # In[167]: mp.prec = 2000 # In[180]: def tupper_field(k): field = np.ndarray((17,106), np.bool) for xix, x in enumerate(mp.arange(0,106)): for yix, y in enumerate(mp.arange(k,k+17)): t1 = mp.floor(y) % 17 t2 = -17*mp.floor(x) t3 = 2**(t2 - t1) t4 = mp.floor(y/17) t5 = (t4 * t3) % 2 field[16-yix, xix] = 0.5 < mp.floor(t5) return field # In[181]: k1 = mp.mpf('820959624942020445814005879832445494830930') k2 = mp.mpf('4858450636189713423582095962494202044581400587983244549483093085061934704708809928450644769865524364849997247024915119110411605739177407856919754326571855442057210445735883681829823754139634338225199452191651284348332905131193199953502413758765239264874613394906870130562295813219481113685339535565290850023875092856892694555974281546386510730049106723058933586052544096664351265349363643957125565695936815184334857605266940161251266951421550539554519153785457525756590740540157929001765967965480064427829131488548259914721248506352686630476300') # In[182]: for k in [k1,k2]: f = tupper_field(k) ax = plt.imshow(f, cmap='Greys', interpolation='nearest') ax.axes.axis('off') plt.show()