The rational number 33/20 as a set

One way to define a rational number (a-b)/c is to define it as the (infinite) set of all 3-tuples of natural numbers (a1, b1, c1) for which (a-b)/c = (a1-b1)/c1 (b is needed for negative numbers).

Klick on a 3-tuple to see how it may be defined as a set.

33/20 = (33-0)/20 = {

( 33, 0, 20 ),

( 66, 0, 40 ), ( 66, 33, 20 ),

( 99, 0, 60 ), ( 99, 33, 40 ), ( 99, 66, 20 ),

( 132, 0, 80 ), ( 132, 33, 60 ), ( 132, 66, 40 ), ( 132, 99, 20 ),

( 165, 0, 100 ), ( 165, 33, 80 ), ( 165, 66, 60 ), ( 165, 99, 40 ), ( 165, 132, 20 ),

( 198, 0, 120 ), ( 198, 33, 100 ), ( 198, 66, 80 ), ( 198, 99, 60 ), ( 198, 132, 40 ), ( 198, 165, 20 ),

( 231, 0, 140 ), ( 231, 33, 120 ), ( 231, 66, 100 ), ( 231, 99, 80 ), ( 231, 132, 60 ), ( 231, 165, 40 ), ( 231, 198, 20 ),

( 264, 0, 160 ), ( 264, 33, 140 ), ( 264, 66, 120 ), ( 264, 99, 100 ), ( 264, 132, 80 ), ( 264, 165, 60 ), ( 264, 198, 40 ), ( 264, 231, 20 ),

( 297, 0, 180 ), ( 297, 33, 160 ), ( 297, 66, 140 ), ( 297, 99, 120 ), ( 297, 132, 100 ), ( 297, 165, 80 ), ( 297, 198, 60 ), ( 297, 231, 40 ), ( 297, 264, 20 ),

( 330, 0, 200 ), ( 330, 33, 180 ), ( 330, 66, 160 ), ( 330, 99, 140 ), ( 330, 132, 120 ), ( 330, 165, 100 ), ( 330, 198, 80 ), ( 330, 231, 60 ), ( 330, 264, 40 ), ( 330, 297, 20 ),

( 363, 0, 220 ), ( 363, 33, 200 ), ( 363, 66, 180 ), ( 363, 99, 160 ), ( 363, 132, 140 ), ( 363, 165, 120 ), ( 363, 198, 100 ), ( 363, 231, 80 ), ( 363, 264, 60 ), ( 363, 297, 40 ), ( 363, 330, 20 ),

( 396, 0, 240 ), ( 396, 33, 220 ), ( 396, 66, 200 ), ( 396, 99, 180 ), ( 396, 132, 160 ), ( 396, 165, 140 ), ( 396, 198, 120 ), ( 396, 231, 100 ), ( 396, 264, 80 ), ( 396, 297, 60 ), ( 396, 330, 40 ), ( 396, 363, 20 ),

( 429, 0, 260 ), ( 429, 33, 240 ), ( 429, 66, 220 ), ( 429, 99, 200 ), ( 429, 132, 180 ), ( 429, 165, 160 ), ( 429, 198, 140 ), ( 429, 231, 120 ), ( 429, 264, 100 ), ( 429, 297, 80 ), ( 429, 330, 60 ), ( 429, 363, 40 ), ( 429, 396, 20 ),

( 462, 0, 280 ), ( 462, 33, 260 ), ( 462, 66, 240 ), ( 462, 99, 220 ), ( 462, 132, 200 ), ( 462, 165, 180 ), ( 462, 198, 160 ), ( 462, 231, 140 ), ( 462, 264, 120 ), ( 462, 297, 100 ), ( 462, 330, 80 ), ( 462, 363, 60 ), ( 462, 396, 40 ), ( 462, 429, 20 ),

...

}

The equation (a-b)/c = (a1-b1)/c1 is equivalent to a·c1 + b1·c = a1·c + b·c1 - so only addition and multiplication of natural numbers are needed to define the rational numbers.

For rational numbers Q, Q1 as defined above, Q < Q1 is defined as a·c1 + b1·c < a1·c + b·c1 for one/all (a, b, c) ∈ Q, (a1, b1, c1) ∈ Q1.

Q + Q1 is defined as (a2-b2)/c2, where a2 = a·c1 + a1·c, b2 = b·c1 + b1·c, c2 = c·c1 for one/all (a, b, c) ∈ Q, (a1, b1, c1) ∈ Q1.

Be aware that (a2-b2)/c2 is simply a notation for the set determined by a2, b2 and c2 here - not an expression using subtraction and division.

The definition for Q + Q1 above simply is a transformation of the expression (a-b)/c + (a1-b1)/c1.

Assuming that a,c is minimal for a positive rational number a/c or (a-0)/c, we can enumerate all members of the set by doing this:

Let n be 1
Repeat:
  For all n1 from 0 to n-1:
    Let a1 be n·a
    Let b1 be n1·a
    Let c1 be (n-n1)·c
    Enumerate (a1,b1,c1)
  Increase n by 1

The enumeration as Python function with a limiting parameter k which will cause the function to enumerate (k·(k+1))/2 elements of a/c:

def print_rational_number(a,c,k):
    print str(a)+'/'+str(c)+' = ('+str(a)+'-0)/'+str(c)+' = {'
    for n in range(1,k+1):
        for n1 in range(n):
            a1=n*a
            b1=n1*a
            c1=(n-n1)*c
            print '( '+str(a1)+', '+str(b1)+', '+str(c1)+' ),'
        print
    print "..."
    print "}"

(back to √2)