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

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

( 29, 0, 19 ),

( 58, 0, 38 ), ( 58, 29, 19 ),

( 87, 0, 57 ), ( 87, 29, 38 ), ( 87, 58, 19 ),

( 116, 0, 76 ), ( 116, 29, 57 ), ( 116, 58, 38 ), ( 116, 87, 19 ),

( 145, 0, 95 ), ( 145, 29, 76 ), ( 145, 58, 57 ), ( 145, 87, 38 ), ( 145, 116, 19 ),

( 174, 0, 114 ), ( 174, 29, 95 ), ( 174, 58, 76 ), ( 174, 87, 57 ), ( 174, 116, 38 ), ( 174, 145, 19 ),

( 203, 0, 133 ), ( 203, 29, 114 ), ( 203, 58, 95 ), ( 203, 87, 76 ), ( 203, 116, 57 ), ( 203, 145, 38 ), ( 203, 174, 19 ),

( 232, 0, 152 ), ( 232, 29, 133 ), ( 232, 58, 114 ), ( 232, 87, 95 ), ( 232, 116, 76 ), ( 232, 145, 57 ), ( 232, 174, 38 ), ( 232, 203, 19 ),

( 261, 0, 171 ), ( 261, 29, 152 ), ( 261, 58, 133 ), ( 261, 87, 114 ), ( 261, 116, 95 ), ( 261, 145, 76 ), ( 261, 174, 57 ), ( 261, 203, 38 ), ( 261, 232, 19 ),

( 290, 0, 190 ), ( 290, 29, 171 ), ( 290, 58, 152 ), ( 290, 87, 133 ), ( 290, 116, 114 ), ( 290, 145, 95 ), ( 290, 174, 76 ), ( 290, 203, 57 ), ( 290, 232, 38 ), ( 290, 261, 19 ),

( 319, 0, 209 ), ( 319, 29, 190 ), ( 319, 58, 171 ), ( 319, 87, 152 ), ( 319, 116, 133 ), ( 319, 145, 114 ), ( 319, 174, 95 ), ( 319, 203, 76 ), ( 319, 232, 57 ), ( 319, 261, 38 ), ( 319, 290, 19 ),

( 348, 0, 228 ), ( 348, 29, 209 ), ( 348, 58, 190 ), ( 348, 87, 171 ), ( 348, 116, 152 ), ( 348, 145, 133 ), ( 348, 174, 114 ), ( 348, 203, 95 ), ( 348, 232, 76 ), ( 348, 261, 57 ), ( 348, 290, 38 ), ( 348, 319, 19 ),

( 377, 0, 247 ), ( 377, 29, 228 ), ( 377, 58, 209 ), ( 377, 87, 190 ), ( 377, 116, 171 ), ( 377, 145, 152 ), ( 377, 174, 133 ), ( 377, 203, 114 ), ( 377, 232, 95 ), ( 377, 261, 76 ), ( 377, 290, 57 ), ( 377, 319, 38 ), ( 377, 348, 19 ),

( 406, 0, 266 ), ( 406, 29, 247 ), ( 406, 58, 228 ), ( 406, 87, 209 ), ( 406, 116, 190 ), ( 406, 145, 171 ), ( 406, 174, 152 ), ( 406, 203, 133 ), ( 406, 232, 114 ), ( 406, 261, 95 ), ( 406, 290, 76 ), ( 406, 319, 57 ), ( 406, 348, 38 ), ( 406, 377, 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)