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

( 29, 0, 5 ),

( 58, 0, 10 ), ( 58, 29, 5 ),

( 87, 0, 15 ), ( 87, 29, 10 ), ( 87, 58, 5 ),

( 116, 0, 20 ), ( 116, 29, 15 ), ( 116, 58, 10 ), ( 116, 87, 5 ),

( 145, 0, 25 ), ( 145, 29, 20 ), ( 145, 58, 15 ), ( 145, 87, 10 ), ( 145, 116, 5 ),

( 174, 0, 30 ), ( 174, 29, 25 ), ( 174, 58, 20 ), ( 174, 87, 15 ), ( 174, 116, 10 ), ( 174, 145, 5 ),

( 203, 0, 35 ), ( 203, 29, 30 ), ( 203, 58, 25 ), ( 203, 87, 20 ), ( 203, 116, 15 ), ( 203, 145, 10 ), ( 203, 174, 5 ),

( 232, 0, 40 ), ( 232, 29, 35 ), ( 232, 58, 30 ), ( 232, 87, 25 ), ( 232, 116, 20 ), ( 232, 145, 15 ), ( 232, 174, 10 ), ( 232, 203, 5 ),

( 261, 0, 45 ), ( 261, 29, 40 ), ( 261, 58, 35 ), ( 261, 87, 30 ), ( 261, 116, 25 ), ( 261, 145, 20 ), ( 261, 174, 15 ), ( 261, 203, 10 ), ( 261, 232, 5 ),

( 290, 0, 50 ), ( 290, 29, 45 ), ( 290, 58, 40 ), ( 290, 87, 35 ), ( 290, 116, 30 ), ( 290, 145, 25 ), ( 290, 174, 20 ), ( 290, 203, 15 ), ( 290, 232, 10 ), ( 290, 261, 5 ),

( 319, 0, 55 ), ( 319, 29, 50 ), ( 319, 58, 45 ), ( 319, 87, 40 ), ( 319, 116, 35 ), ( 319, 145, 30 ), ( 319, 174, 25 ), ( 319, 203, 20 ), ( 319, 232, 15 ), ( 319, 261, 10 ), ( 319, 290, 5 ),

( 348, 0, 60 ), ( 348, 29, 55 ), ( 348, 58, 50 ), ( 348, 87, 45 ), ( 348, 116, 40 ), ( 348, 145, 35 ), ( 348, 174, 30 ), ( 348, 203, 25 ), ( 348, 232, 20 ), ( 348, 261, 15 ), ( 348, 290, 10 ), ( 348, 319, 5 ),

( 377, 0, 65 ), ( 377, 29, 60 ), ( 377, 58, 55 ), ( 377, 87, 50 ), ( 377, 116, 45 ), ( 377, 145, 40 ), ( 377, 174, 35 ), ( 377, 203, 30 ), ( 377, 232, 25 ), ( 377, 261, 20 ), ( 377, 290, 15 ), ( 377, 319, 10 ), ( 377, 348, 5 ),

( 406, 0, 70 ), ( 406, 29, 65 ), ( 406, 58, 60 ), ( 406, 87, 55 ), ( 406, 116, 50 ), ( 406, 145, 45 ), ( 406, 174, 40 ), ( 406, 203, 35 ), ( 406, 232, 30 ), ( 406, 261, 25 ), ( 406, 290, 20 ), ( 406, 319, 15 ), ( 406, 348, 10 ), ( 406, 377, 5 ),

...

}

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)