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

37/3 = (37-0)/3 = {

( 37, 0, 3 ),

( 74, 0, 6 ), ( 74, 37, 3 ),

( 111, 0, 9 ), ( 111, 37, 6 ), ( 111, 74, 3 ),

( 148, 0, 12 ), ( 148, 37, 9 ), ( 148, 74, 6 ), ( 148, 111, 3 ),

( 185, 0, 15 ), ( 185, 37, 12 ), ( 185, 74, 9 ), ( 185, 111, 6 ), ( 185, 148, 3 ),

( 222, 0, 18 ), ( 222, 37, 15 ), ( 222, 74, 12 ), ( 222, 111, 9 ), ( 222, 148, 6 ), ( 222, 185, 3 ),

( 259, 0, 21 ), ( 259, 37, 18 ), ( 259, 74, 15 ), ( 259, 111, 12 ), ( 259, 148, 9 ), ( 259, 185, 6 ), ( 259, 222, 3 ),

( 296, 0, 24 ), ( 296, 37, 21 ), ( 296, 74, 18 ), ( 296, 111, 15 ), ( 296, 148, 12 ), ( 296, 185, 9 ), ( 296, 222, 6 ), ( 296, 259, 3 ),

( 333, 0, 27 ), ( 333, 37, 24 ), ( 333, 74, 21 ), ( 333, 111, 18 ), ( 333, 148, 15 ), ( 333, 185, 12 ), ( 333, 222, 9 ), ( 333, 259, 6 ), ( 333, 296, 3 ),

( 370, 0, 30 ), ( 370, 37, 27 ), ( 370, 74, 24 ), ( 370, 111, 21 ), ( 370, 148, 18 ), ( 370, 185, 15 ), ( 370, 222, 12 ), ( 370, 259, 9 ), ( 370, 296, 6 ), ( 370, 333, 3 ),

( 407, 0, 33 ), ( 407, 37, 30 ), ( 407, 74, 27 ), ( 407, 111, 24 ), ( 407, 148, 21 ), ( 407, 185, 18 ), ( 407, 222, 15 ), ( 407, 259, 12 ), ( 407, 296, 9 ), ( 407, 333, 6 ), ( 407, 370, 3 ),

( 444, 0, 36 ), ( 444, 37, 33 ), ( 444, 74, 30 ), ( 444, 111, 27 ), ( 444, 148, 24 ), ( 444, 185, 21 ), ( 444, 222, 18 ), ( 444, 259, 15 ), ( 444, 296, 12 ), ( 444, 333, 9 ), ( 444, 370, 6 ), ( 444, 407, 3 ),

( 481, 0, 39 ), ( 481, 37, 36 ), ( 481, 74, 33 ), ( 481, 111, 30 ), ( 481, 148, 27 ), ( 481, 185, 24 ), ( 481, 222, 21 ), ( 481, 259, 18 ), ( 481, 296, 15 ), ( 481, 333, 12 ), ( 481, 370, 9 ), ( 481, 407, 6 ), ( 481, 444, 3 ),

( 518, 0, 42 ), ( 518, 37, 39 ), ( 518, 74, 36 ), ( 518, 111, 33 ), ( 518, 148, 30 ), ( 518, 185, 27 ), ( 518, 222, 24 ), ( 518, 259, 21 ), ( 518, 296, 18 ), ( 518, 333, 15 ), ( 518, 370, 12 ), ( 518, 407, 9 ), ( 518, 444, 6 ), ( 518, 481, 3 ),

...

}

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)