The rational number 29/6 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.

29/6 = (29-0)/6 = {

( 29, 0, 6 ),

( 58, 0, 12 ), ( 58, 29, 6 ),

( 87, 0, 18 ), ( 87, 29, 12 ), ( 87, 58, 6 ),

( 116, 0, 24 ), ( 116, 29, 18 ), ( 116, 58, 12 ), ( 116, 87, 6 ),

( 145, 0, 30 ), ( 145, 29, 24 ), ( 145, 58, 18 ), ( 145, 87, 12 ), ( 145, 116, 6 ),

( 174, 0, 36 ), ( 174, 29, 30 ), ( 174, 58, 24 ), ( 174, 87, 18 ), ( 174, 116, 12 ), ( 174, 145, 6 ),

( 203, 0, 42 ), ( 203, 29, 36 ), ( 203, 58, 30 ), ( 203, 87, 24 ), ( 203, 116, 18 ), ( 203, 145, 12 ), ( 203, 174, 6 ),

( 232, 0, 48 ), ( 232, 29, 42 ), ( 232, 58, 36 ), ( 232, 87, 30 ), ( 232, 116, 24 ), ( 232, 145, 18 ), ( 232, 174, 12 ), ( 232, 203, 6 ),

( 261, 0, 54 ), ( 261, 29, 48 ), ( 261, 58, 42 ), ( 261, 87, 36 ), ( 261, 116, 30 ), ( 261, 145, 24 ), ( 261, 174, 18 ), ( 261, 203, 12 ), ( 261, 232, 6 ),

( 290, 0, 60 ), ( 290, 29, 54 ), ( 290, 58, 48 ), ( 290, 87, 42 ), ( 290, 116, 36 ), ( 290, 145, 30 ), ( 290, 174, 24 ), ( 290, 203, 18 ), ( 290, 232, 12 ), ( 290, 261, 6 ),

( 319, 0, 66 ), ( 319, 29, 60 ), ( 319, 58, 54 ), ( 319, 87, 48 ), ( 319, 116, 42 ), ( 319, 145, 36 ), ( 319, 174, 30 ), ( 319, 203, 24 ), ( 319, 232, 18 ), ( 319, 261, 12 ), ( 319, 290, 6 ),

( 348, 0, 72 ), ( 348, 29, 66 ), ( 348, 58, 60 ), ( 348, 87, 54 ), ( 348, 116, 48 ), ( 348, 145, 42 ), ( 348, 174, 36 ), ( 348, 203, 30 ), ( 348, 232, 24 ), ( 348, 261, 18 ), ( 348, 290, 12 ), ( 348, 319, 6 ),

( 377, 0, 78 ), ( 377, 29, 72 ), ( 377, 58, 66 ), ( 377, 87, 60 ), ( 377, 116, 54 ), ( 377, 145, 48 ), ( 377, 174, 42 ), ( 377, 203, 36 ), ( 377, 232, 30 ), ( 377, 261, 24 ), ( 377, 290, 18 ), ( 377, 319, 12 ), ( 377, 348, 6 ),

( 406, 0, 84 ), ( 406, 29, 78 ), ( 406, 58, 72 ), ( 406, 87, 66 ), ( 406, 116, 60 ), ( 406, 145, 54 ), ( 406, 174, 48 ), ( 406, 203, 42 ), ( 406, 232, 36 ), ( 406, 261, 30 ), ( 406, 290, 24 ), ( 406, 319, 18 ), ( 406, 348, 12 ), ( 406, 377, 6 ),

...

}

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)