How to resolve the algorithm Tupper's self-referential formula step by step in the J programming language

Published on 12 May 2024 09:40 PM
#J

How to resolve the algorithm Tupper's self-referential formula step by step in the J programming language

Table of Contents

Problem Statement

Jeff Tupper, in his 2001 paper "Reliable Two-Dimensional Graphing Methods for Mathematical Formulae with Two Free Variables", shows a set of methods to graph equations and inequalities with two variables in the cartesian plane. One of the examples of the paper, refers to the inequality:

1 2

<

m o d

(

y 17

2

− 17 ⌊ x ⌋ −

m o d

(

⌊ y ⌋ , 17

)

, 2

)

{\displaystyle {\frac {1}{2}}<\left\lfloor \mathrm {mod} \left(\left\lfloor {\frac {y}{17}}\right\rfloor 2^{-17\lfloor x\rfloor -\mathrm {mod} \left(\lfloor y\rfloor ,17\right)},2\right)\right\rfloor }

That inequality, once plotted in the range 0 ≤ x ≤ 106 and k ≤ y ≤ k + 17 for k = 960, 939, 379, 918, 958, 884, 971, 672, 962, 127, 852, 754, 715, 004, 339, 660, 129, 306, 651, 505, 519, 271, 702, 802, 395, 266, 424, 689, 642, 842, 174, 350, 718, 121, 267, 153, 782, 770, 623, 355, 993, 237, 280, 874, 144, 307, 891, 325, 963, 941, 337, 723, 487, 857, 735, 749, 823, 926, 629, 715, 517, 173, 716, 995, 165, 232, 890, 538, 221, 612, 403, 238, 855, 866, 184, 013, 235, 585, 136, 048, 828, 693, 337, 902, 491, 454, 229, 288, 667, 081, 096, 184, 496, 091, 705, 183, 454, 067, 827, 731, 551, 705, 405, 381, 627, 380, 967, 602, 565, 625, 016, 981, 482, 083, 418, 783, 163, 849, 115, 590, 225, 610, 003, 652, 351, 370, 343, 874, 461, 848, 378, 737, 238, 198, 224, 849, 863, 465, 033, 159, 410, 054, 974, 700, 593, 138, 339, 226, 497, 249, 461, 751, 545, 728, 366, 702, 369, 745, 461, 014, 655, 997, 933, 798, 537, 483, 143, 786, 841, 806, 593, 422, 227, 898, 388, 722, 980, 000, 748, 404, 719 produces a drawing that visually mimics the inequality itself, hence it is called self-referential. Although the inequality is intended to be drawn on the continuum of the cartesian plane, the drawing can be performed iterating over the integer values of both the horizontal and vertical ranges. Make a drawing of the Tupper's formula, either using text, a matrix or creating an image. This task requires arbitrary precision integer operations. If your language does not intrinsically support that, you can use a library. The value of k is an encoding of the bitmap of the image, therefore any 17-width bitmap can be produced, using its associated encoded value as k.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Tupper's self-referential formula step by step in the J programming language

Source code in the j programming language

K=. (". (0 ( : 0)) -. LF)"_
960939379918958884971672962127852754715004339660129306651505
519271702802395266424689642842174350718121267153782770623355
993237280874144307891325963941337723487857735749823926629715
517173716995165232890538221612403238855866184013235585136048
828693337902491454229288667081096184496091705183454067827731
551705405381627380967602565625016981482083418783163849115590
225610003652351370343874461848378737238198224849863465033159
410054974700593138339226497249461751545728366702369745461014
655997933798537483143786841806593422227898388722980000748404
719x
)

inequality=. 1r2 < <. o (2 | (17 %~ ]) * 2 ^ (_17 * <. o [) - 17x | <.(o=. @:)])

Tupperimage=. ({&' *') o ([ (] inequality K + [)"0/ |. o ])&:i. f.


   17 Tupperimage 106


   _80 [\ (5!:5) <'Tupperimage'
{&' *'@:([ (] (1r2 < <.@:(2 | (17 %~ ]) * 2 ^ (_17 * <.@:[) - 17x | <.@:])) 9609
39379918958884971672962127852754715004339660129306651505519271702802395266424689
64284217435071812126715378277062335599323728087414430789132596394133772348785773
57498239266297155171737169951652328905382216124032388558661840132355851360488286
93337902491454229288667081096184496091705183454067827731551705405381627380967602
56562501698148208341878316384911559022561000365235137034387446184837873723819822
48498634650331594100549747005931383392264972494617515457283667023697454610146559
97933798537483143786841806593422227898388722980000748404719x"_ + [)"0/ |.@:])&:i
.


Tuppergraph=. viewmat o ([ load o ('viewmat'"_)) o ([ (] inequality K + [)"0/ |. o ])&:i.

17 Tuppergraph 106


  

You may also check:How to resolve the algorithm ABC problem step by step in the M2000 Interpreter programming language
You may also check:How to resolve the algorithm Sudoku step by step in the Bracmat programming language
You may also check:How to resolve the algorithm Long multiplication step by step in the ALGOL 60 programming language
You may also check:How to resolve the algorithm Program termination step by step in the AutoIt programming language
You may also check:How to resolve the algorithm Create a two-dimensional array at runtime step by step in the Quackery programming language