Talk:Tupper's self-referential formula: Difference between revisions

From Rosetta Code
Content added Content deleted
Line 12: Line 12:
== Simplification of Tupper's formula for discrete plotting ==
== Simplification of Tupper's formula for discrete plotting ==


As the task description suggests, and [[user|Tigerofdarkness]] states, Tupper's formula can be simplified when evaluated with integer values, i.e. ⌊x⌋ can be simplified to just x. As a second example, given that mod(x, 2) can only result in either 0 or 1, the outermost comparison can be turned to be an equality against 1.
As the task description suggests, and [[user|Tigerofdarkness]] states, Tupper's formula can be simplified when evaluated with integer values, i.e. ⌊x⌋ can be simplified to just x. As a second example, given that mod(x, 2) can only result in either 0 or 1, the outermost comparison can be turned out to be an equality against 1.


The most simplified version I have found (with verification in program), which uses only operations of addition, multiplication, exponentiation (with no negative values, deriving in rational numbers), div, mod, no floor, and equality of integer numbers is:
The most simplified version I have achieved (with verification in program), which uses only operations of addition, multiplication, exponentiation (with no negative values, deriving in rational numbers), div, mod, no floor, and equality of integer numbers is:


<math display=block>\mathrm{mod}\left( \mathrm{div} \left( \mathrm{div} \left( y , 17 \right) , 2^{17 x + \mathrm{mod} \left( y , 17 \right) } \right), 2 \right) = 1</math>
<math display=block>\mathrm{mod}\left( \mathrm{div} \left( \mathrm{div} \left( y , 17 \right) , 2^{17 x + \mathrm{mod} \left( y , 17 \right) } \right), 2 \right) = 1</math>

Revision as of 01:53, 9 July 2023

Ranges of x and y

The Wikipedia article states the ranges of x and y are 0 <= x < 106 and k <= y < k + 17, which seems to be what most of the samples are using. --Tigerofdarkness (talk) 21:50, 7 July 2023 (UTC)

Hi. The Wikipedia article explains Tupper's formulae as a continuous function (or relation, or inequality) to be drawn in the 2D cartesian plane, not a discrete inequality. I think the source of ambiguity is a fencepost error. When plotting in "discrete" form, it is enough to iterate from 0 to 105. Laurence (talk) 18:45, 8 July 2023 (UTC)

When drawing the bitmap in the Algol 68 sample, I found that x=105 is the lefthand edge and the x loop has to run backwards from 105 to 0. (actually runs from 106 to add a "border")
Am I doing something wrong ? --Tigerofdarkness (talk) 11:14, 8 July 2023 (UTC)

You are right, it is enough to iterate from 0 to 105, not up to 106. Iterating to 106 produces an "empty" vertical line at the left of the drawing (leftmost column empty, when a matrix is generated). Laurence (talk) 18:45, 8 July 2023 (UTC)

Simplification of Tupper's formula for discrete plotting

As the task description suggests, and Tigerofdarkness states, Tupper's formula can be simplified when evaluated with integer values, i.e. ⌊x⌋ can be simplified to just x. As a second example, given that mod(x, 2) can only result in either 0 or 1, the outermost comparison can be turned out to be an equality against 1.

The most simplified version I have achieved (with verification in program), which uses only operations of addition, multiplication, exponentiation (with no negative values, deriving in rational numbers), div, mod, no floor, and equality of integer numbers is:

Laurence (talk) 21:20, 8 July 2023 (UTC)