Tupper's self-referential formula: Difference between revisions

m
(Add C# implementation)
 
(2 intermediate revisions by 2 users not shown)
Line 233:
First, let us make the definition of k:
 
[[File:Fōrmulæ - Tupper's self-referential formula 01a01.png]]
 
Tupper uses the notation '''mod(a, b)''' for the modulo operation, while Fōrmulæ uses the notation '''a Mod b'''. If we want to use the Tupper's formula exactly as it is, we can use the trick:
Line 241:
Now we can use a formula that looks exactly as Tupper's:
 
[[File:Fōrmulæ - Tupper's self-referential formula 03a03.png]]
 
'''Visualization as a matrix.''' The following creates a 17×106 matrix. Values for which inequality is true are shown as an opaque black color, otherwise they are shown as an transparent color.
Line 248:
 
(image is resized 50% of its original)
 
[[File:Fōrmulæ - Tupper's self-referential formula 05.png|1070px]]
 
'''Visualization as an image.''' In the following script, a function to draw the Tupper's formula is used to generate the image with different sizes, because the standard 1x1 pixel per unit results to be too small in order to be appreciated:
 
[[File:Fōrmulæ - Tupper's self-referential formula 06a06.png]]
 
[[File:Fōrmulæ - Tupper's self-referential formula 0807.png]]
 
[[File:Fōrmulæ - Tupper's self-referential formula 07a08.png]]
 
=={{header|J}}==
Line 466 ⟶ 467:
{{out}}
Same as Algol 68.
 
=={{header|Mathematica}}/{{header|Wolfram Language}}==
{{trans|Julia}}
<syntaxhighlight lang="Mathematica">
(*Define the Tupper's self-referential formula function*)
tupperMat[k_] :=
Table[1 -
Mod[Floor[Mod[Floor[y/17] 2^(-17 Floor[x] - Mod[y, 17]), 2]],
2], {y, k, k + 16}, {x, 0, 105}]
 
(*Define the constant k*)
k = 960939379918958884971672962127852754715004339660129306651505519271\
7028023952664246896428421743507181212671537827706233559932372808741443\
0789132596394133772348785773574982392662971551717371699516523289053822\
1612403238855866184013235585136048828693337902491454229288667081096184\
4960917051834540678277315517054053816273809676025656250169814820834187\
8316384911559022561000365235137034387446184837873723819822484986346503\
3159410054974700593138339226497249461751545728366702369745461014655997\
933798537483143786841806593422227898388722980000748404719;
 
(*Display the heatmap*)
ArrayPlot[Map[Reverse, tupperMat[k]], AspectRatio -> 1/6,
Frame -> False, ImageSize -> Large,
ColorRules -> {0 -> Black, 1 -> White}]
</syntaxhighlight>
{{out}}
[[File:Tupper's self-referential formula.png|thumb]]
 
 
 
=={{header|Nim}}==
Line 705 ⟶ 735:
 
The culprit here is BigRat which is written entirely in Wren and always uses maximum precision. Unfortunately, we can't use GMP in a DOME application which would be much faster than this.
<syntaxhighlight lang="ecmascriptwren">import "dome" for Window
import "graphics" for Canvas, Color, Font
import "./plot" for Axes
2,120

edits