The rational number 34/7 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/7 = (34-0)/7 = {

( 34, 0, 7 ),

( 68, 0, 14 ), ( 68, 34, 7 ),

( 102, 0, 21 ), ( 102, 34, 14 ), ( 102, 68, 7 ),

( 136, 0, 28 ), ( 136, 34, 21 ), ( 136, 68, 14 ), ( 136, 102, 7 ),

( 170, 0, 35 ), ( 170, 34, 28 ), ( 170, 68, 21 ), ( 170, 102, 14 ), ( 170, 136, 7 ),

( 204, 0, 42 ), ( 204, 34, 35 ), ( 204, 68, 28 ), ( 204, 102, 21 ), ( 204, 136, 14 ), ( 204, 170, 7 ),

( 238, 0, 49 ), ( 238, 34, 42 ), ( 238, 68, 35 ), ( 238, 102, 28 ), ( 238, 136, 21 ), ( 238, 170, 14 ), ( 238, 204, 7 ),

( 272, 0, 56 ), ( 272, 34, 49 ), ( 272, 68, 42 ), ( 272, 102, 35 ), ( 272, 136, 28 ), ( 272, 170, 21 ), ( 272, 204, 14 ), ( 272, 238, 7 ),

( 306, 0, 63 ), ( 306, 34, 56 ), ( 306, 68, 49 ), ( 306, 102, 42 ), ( 306, 136, 35 ), ( 306, 170, 28 ), ( 306, 204, 21 ), ( 306, 238, 14 ), ( 306, 272, 7 ),

( 340, 0, 70 ), ( 340, 34, 63 ), ( 340, 68, 56 ), ( 340, 102, 49 ), ( 340, 136, 42 ), ( 340, 170, 35 ), ( 340, 204, 28 ), ( 340, 238, 21 ), ( 340, 272, 14 ), ( 340, 306, 7 ),

( 374, 0, 77 ), ( 374, 34, 70 ), ( 374, 68, 63 ), ( 374, 102, 56 ), ( 374, 136, 49 ), ( 374, 170, 42 ), ( 374, 204, 35 ), ( 374, 238, 28 ), ( 374, 272, 21 ), ( 374, 306, 14 ), ( 374, 340, 7 ),

( 408, 0, 84 ), ( 408, 34, 77 ), ( 408, 68, 70 ), ( 408, 102, 63 ), ( 408, 136, 56 ), ( 408, 170, 49 ), ( 408, 204, 42 ), ( 408, 238, 35 ), ( 408, 272, 28 ), ( 408, 306, 21 ), ( 408, 340, 14 ), ( 408, 374, 7 ),

( 442, 0, 91 ), ( 442, 34, 84 ), ( 442, 68, 77 ), ( 442, 102, 70 ), ( 442, 136, 63 ), ( 442, 170, 56 ), ( 442, 204, 49 ), ( 442, 238, 42 ), ( 442, 272, 35 ), ( 442, 306, 28 ), ( 442, 340, 21 ), ( 442, 374, 14 ), ( 442, 408, 7 ),

( 476, 0, 98 ), ( 476, 34, 91 ), ( 476, 68, 84 ), ( 476, 102, 77 ), ( 476, 136, 70 ), ( 476, 170, 63 ), ( 476, 204, 56 ), ( 476, 238, 49 ), ( 476, 272, 42 ), ( 476, 306, 35 ), ( 476, 340, 28 ), ( 476, 374, 21 ), ( 476, 408, 14 ), ( 476, 442, 7 ),

...

}

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)