The rational number 34/19 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.

34/19 = (34-0)/19 = {

( 34, 0, 19 ),

( 68, 0, 38 ), ( 68, 34, 19 ),

( 102, 0, 57 ), ( 102, 34, 38 ), ( 102, 68, 19 ),

( 136, 0, 76 ), ( 136, 34, 57 ), ( 136, 68, 38 ), ( 136, 102, 19 ),

( 170, 0, 95 ), ( 170, 34, 76 ), ( 170, 68, 57 ), ( 170, 102, 38 ), ( 170, 136, 19 ),

( 204, 0, 114 ), ( 204, 34, 95 ), ( 204, 68, 76 ), ( 204, 102, 57 ), ( 204, 136, 38 ), ( 204, 170, 19 ),

( 238, 0, 133 ), ( 238, 34, 114 ), ( 238, 68, 95 ), ( 238, 102, 76 ), ( 238, 136, 57 ), ( 238, 170, 38 ), ( 238, 204, 19 ),

( 272, 0, 152 ), ( 272, 34, 133 ), ( 272, 68, 114 ), ( 272, 102, 95 ), ( 272, 136, 76 ), ( 272, 170, 57 ), ( 272, 204, 38 ), ( 272, 238, 19 ),

( 306, 0, 171 ), ( 306, 34, 152 ), ( 306, 68, 133 ), ( 306, 102, 114 ), ( 306, 136, 95 ), ( 306, 170, 76 ), ( 306, 204, 57 ), ( 306, 238, 38 ), ( 306, 272, 19 ),

( 340, 0, 190 ), ( 340, 34, 171 ), ( 340, 68, 152 ), ( 340, 102, 133 ), ( 340, 136, 114 ), ( 340, 170, 95 ), ( 340, 204, 76 ), ( 340, 238, 57 ), ( 340, 272, 38 ), ( 340, 306, 19 ),

( 374, 0, 209 ), ( 374, 34, 190 ), ( 374, 68, 171 ), ( 374, 102, 152 ), ( 374, 136, 133 ), ( 374, 170, 114 ), ( 374, 204, 95 ), ( 374, 238, 76 ), ( 374, 272, 57 ), ( 374, 306, 38 ), ( 374, 340, 19 ),

( 408, 0, 228 ), ( 408, 34, 209 ), ( 408, 68, 190 ), ( 408, 102, 171 ), ( 408, 136, 152 ), ( 408, 170, 133 ), ( 408, 204, 114 ), ( 408, 238, 95 ), ( 408, 272, 76 ), ( 408, 306, 57 ), ( 408, 340, 38 ), ( 408, 374, 19 ),

( 442, 0, 247 ), ( 442, 34, 228 ), ( 442, 68, 209 ), ( 442, 102, 190 ), ( 442, 136, 171 ), ( 442, 170, 152 ), ( 442, 204, 133 ), ( 442, 238, 114 ), ( 442, 272, 95 ), ( 442, 306, 76 ), ( 442, 340, 57 ), ( 442, 374, 38 ), ( 442, 408, 19 ),

( 476, 0, 266 ), ( 476, 34, 247 ), ( 476, 68, 228 ), ( 476, 102, 209 ), ( 476, 136, 190 ), ( 476, 170, 171 ), ( 476, 204, 152 ), ( 476, 238, 133 ), ( 476, 272, 114 ), ( 476, 306, 95 ), ( 476, 340, 76 ), ( 476, 374, 57 ), ( 476, 408, 38 ), ( 476, 442, 19 ),

...

}

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)