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

( 29, 0, 1 ),

( 58, 0, 2 ), ( 58, 29, 1 ),

( 87, 0, 3 ), ( 87, 29, 2 ), ( 87, 58, 1 ),

( 116, 0, 4 ), ( 116, 29, 3 ), ( 116, 58, 2 ), ( 116, 87, 1 ),

( 145, 0, 5 ), ( 145, 29, 4 ), ( 145, 58, 3 ), ( 145, 87, 2 ), ( 145, 116, 1 ),

( 174, 0, 6 ), ( 174, 29, 5 ), ( 174, 58, 4 ), ( 174, 87, 3 ), ( 174, 116, 2 ), ( 174, 145, 1 ),

( 203, 0, 7 ), ( 203, 29, 6 ), ( 203, 58, 5 ), ( 203, 87, 4 ), ( 203, 116, 3 ), ( 203, 145, 2 ), ( 203, 174, 1 ),

( 232, 0, 8 ), ( 232, 29, 7 ), ( 232, 58, 6 ), ( 232, 87, 5 ), ( 232, 116, 4 ), ( 232, 145, 3 ), ( 232, 174, 2 ), ( 232, 203, 1 ),

( 261, 0, 9 ), ( 261, 29, 8 ), ( 261, 58, 7 ), ( 261, 87, 6 ), ( 261, 116, 5 ), ( 261, 145, 4 ), ( 261, 174, 3 ), ( 261, 203, 2 ), ( 261, 232, 1 ),

( 290, 0, 10 ), ( 290, 29, 9 ), ( 290, 58, 8 ), ( 290, 87, 7 ), ( 290, 116, 6 ), ( 290, 145, 5 ), ( 290, 174, 4 ), ( 290, 203, 3 ), ( 290, 232, 2 ), ( 290, 261, 1 ),

( 319, 0, 11 ), ( 319, 29, 10 ), ( 319, 58, 9 ), ( 319, 87, 8 ), ( 319, 116, 7 ), ( 319, 145, 6 ), ( 319, 174, 5 ), ( 319, 203, 4 ), ( 319, 232, 3 ), ( 319, 261, 2 ), ( 319, 290, 1 ),

( 348, 0, 12 ), ( 348, 29, 11 ), ( 348, 58, 10 ), ( 348, 87, 9 ), ( 348, 116, 8 ), ( 348, 145, 7 ), ( 348, 174, 6 ), ( 348, 203, 5 ), ( 348, 232, 4 ), ( 348, 261, 3 ), ( 348, 290, 2 ), ( 348, 319, 1 ),

( 377, 0, 13 ), ( 377, 29, 12 ), ( 377, 58, 11 ), ( 377, 87, 10 ), ( 377, 116, 9 ), ( 377, 145, 8 ), ( 377, 174, 7 ), ( 377, 203, 6 ), ( 377, 232, 5 ), ( 377, 261, 4 ), ( 377, 290, 3 ), ( 377, 319, 2 ), ( 377, 348, 1 ),

( 406, 0, 14 ), ( 406, 29, 13 ), ( 406, 58, 12 ), ( 406, 87, 11 ), ( 406, 116, 10 ), ( 406, 145, 9 ), ( 406, 174, 8 ), ( 406, 203, 7 ), ( 406, 232, 6 ), ( 406, 261, 5 ), ( 406, 290, 4 ), ( 406, 319, 3 ), ( 406, 348, 2 ), ( 406, 377, 1 ),

...

}

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)