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

( 37, 0, 18 ),

( 74, 0, 36 ), ( 74, 37, 18 ),

( 111, 0, 54 ), ( 111, 37, 36 ), ( 111, 74, 18 ),

( 148, 0, 72 ), ( 148, 37, 54 ), ( 148, 74, 36 ), ( 148, 111, 18 ),

( 185, 0, 90 ), ( 185, 37, 72 ), ( 185, 74, 54 ), ( 185, 111, 36 ), ( 185, 148, 18 ),

( 222, 0, 108 ), ( 222, 37, 90 ), ( 222, 74, 72 ), ( 222, 111, 54 ), ( 222, 148, 36 ), ( 222, 185, 18 ),

( 259, 0, 126 ), ( 259, 37, 108 ), ( 259, 74, 90 ), ( 259, 111, 72 ), ( 259, 148, 54 ), ( 259, 185, 36 ), ( 259, 222, 18 ),

( 296, 0, 144 ), ( 296, 37, 126 ), ( 296, 74, 108 ), ( 296, 111, 90 ), ( 296, 148, 72 ), ( 296, 185, 54 ), ( 296, 222, 36 ), ( 296, 259, 18 ),

( 333, 0, 162 ), ( 333, 37, 144 ), ( 333, 74, 126 ), ( 333, 111, 108 ), ( 333, 148, 90 ), ( 333, 185, 72 ), ( 333, 222, 54 ), ( 333, 259, 36 ), ( 333, 296, 18 ),

( 370, 0, 180 ), ( 370, 37, 162 ), ( 370, 74, 144 ), ( 370, 111, 126 ), ( 370, 148, 108 ), ( 370, 185, 90 ), ( 370, 222, 72 ), ( 370, 259, 54 ), ( 370, 296, 36 ), ( 370, 333, 18 ),

( 407, 0, 198 ), ( 407, 37, 180 ), ( 407, 74, 162 ), ( 407, 111, 144 ), ( 407, 148, 126 ), ( 407, 185, 108 ), ( 407, 222, 90 ), ( 407, 259, 72 ), ( 407, 296, 54 ), ( 407, 333, 36 ), ( 407, 370, 18 ),

( 444, 0, 216 ), ( 444, 37, 198 ), ( 444, 74, 180 ), ( 444, 111, 162 ), ( 444, 148, 144 ), ( 444, 185, 126 ), ( 444, 222, 108 ), ( 444, 259, 90 ), ( 444, 296, 72 ), ( 444, 333, 54 ), ( 444, 370, 36 ), ( 444, 407, 18 ),

( 481, 0, 234 ), ( 481, 37, 216 ), ( 481, 74, 198 ), ( 481, 111, 180 ), ( 481, 148, 162 ), ( 481, 185, 144 ), ( 481, 222, 126 ), ( 481, 259, 108 ), ( 481, 296, 90 ), ( 481, 333, 72 ), ( 481, 370, 54 ), ( 481, 407, 36 ), ( 481, 444, 18 ),

( 518, 0, 252 ), ( 518, 37, 234 ), ( 518, 74, 216 ), ( 518, 111, 198 ), ( 518, 148, 180 ), ( 518, 185, 162 ), ( 518, 222, 144 ), ( 518, 259, 126 ), ( 518, 296, 108 ), ( 518, 333, 90 ), ( 518, 370, 72 ), ( 518, 407, 54 ), ( 518, 444, 36 ), ( 518, 481, 18 ),

...

}

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)