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

( 29, 0, 9 ),

( 58, 0, 18 ), ( 58, 29, 9 ),

( 87, 0, 27 ), ( 87, 29, 18 ), ( 87, 58, 9 ),

( 116, 0, 36 ), ( 116, 29, 27 ), ( 116, 58, 18 ), ( 116, 87, 9 ),

( 145, 0, 45 ), ( 145, 29, 36 ), ( 145, 58, 27 ), ( 145, 87, 18 ), ( 145, 116, 9 ),

( 174, 0, 54 ), ( 174, 29, 45 ), ( 174, 58, 36 ), ( 174, 87, 27 ), ( 174, 116, 18 ), ( 174, 145, 9 ),

( 203, 0, 63 ), ( 203, 29, 54 ), ( 203, 58, 45 ), ( 203, 87, 36 ), ( 203, 116, 27 ), ( 203, 145, 18 ), ( 203, 174, 9 ),

( 232, 0, 72 ), ( 232, 29, 63 ), ( 232, 58, 54 ), ( 232, 87, 45 ), ( 232, 116, 36 ), ( 232, 145, 27 ), ( 232, 174, 18 ), ( 232, 203, 9 ),

( 261, 0, 81 ), ( 261, 29, 72 ), ( 261, 58, 63 ), ( 261, 87, 54 ), ( 261, 116, 45 ), ( 261, 145, 36 ), ( 261, 174, 27 ), ( 261, 203, 18 ), ( 261, 232, 9 ),

( 290, 0, 90 ), ( 290, 29, 81 ), ( 290, 58, 72 ), ( 290, 87, 63 ), ( 290, 116, 54 ), ( 290, 145, 45 ), ( 290, 174, 36 ), ( 290, 203, 27 ), ( 290, 232, 18 ), ( 290, 261, 9 ),

( 319, 0, 99 ), ( 319, 29, 90 ), ( 319, 58, 81 ), ( 319, 87, 72 ), ( 319, 116, 63 ), ( 319, 145, 54 ), ( 319, 174, 45 ), ( 319, 203, 36 ), ( 319, 232, 27 ), ( 319, 261, 18 ), ( 319, 290, 9 ),

( 348, 0, 108 ), ( 348, 29, 99 ), ( 348, 58, 90 ), ( 348, 87, 81 ), ( 348, 116, 72 ), ( 348, 145, 63 ), ( 348, 174, 54 ), ( 348, 203, 45 ), ( 348, 232, 36 ), ( 348, 261, 27 ), ( 348, 290, 18 ), ( 348, 319, 9 ),

( 377, 0, 117 ), ( 377, 29, 108 ), ( 377, 58, 99 ), ( 377, 87, 90 ), ( 377, 116, 81 ), ( 377, 145, 72 ), ( 377, 174, 63 ), ( 377, 203, 54 ), ( 377, 232, 45 ), ( 377, 261, 36 ), ( 377, 290, 27 ), ( 377, 319, 18 ), ( 377, 348, 9 ),

( 406, 0, 126 ), ( 406, 29, 117 ), ( 406, 58, 108 ), ( 406, 87, 99 ), ( 406, 116, 90 ), ( 406, 145, 81 ), ( 406, 174, 72 ), ( 406, 203, 63 ), ( 406, 232, 54 ), ( 406, 261, 45 ), ( 406, 290, 36 ), ( 406, 319, 27 ), ( 406, 348, 18 ), ( 406, 377, 9 ),

...

}

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)