Talk:Tupper's self-referential formula

From Rosetta Code

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 exponents, deriving in rational numbers), div, mod, no floor, and equality of integer numbers is:

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


Currently, the task says "k ≤ y ≤ k + 17 for k = 960, 939, ..."

But, looking at the implementations, it seems clear that y ranges from 0..17 (or 0..16) and is never greater than any values from k. --Rdm (talk) 14:02, 10 July 2023 (UTC)

Suppose you have to plot the function y = ⌊x⌋ for 0 ≤ x ≤ 3. It will produce a "staircase" with three horizontal "steps". You can decide to optimize it, plotting in "discrete mode": For each integer value drawing a line 0.999... units long at the "right" direction, in such that case you have to draw three segments, the first one starting at 0 (in x) the second one starting at 1, and the third one starting at 2. However, no segment must be drawn starting at 3, because it would end at 3.999..., outside the required range.
The Tupper's formula is similar, but in two-dimensions, it produces solid blocks 0.999.. x 0.999... units in area, instead of lines. Laurence (talk) 23:38, 10 July 2023 (UTC)