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

( 37, 0, 23 ),

( 74, 0, 46 ), ( 74, 37, 23 ),

( 111, 0, 69 ), ( 111, 37, 46 ), ( 111, 74, 23 ),

( 148, 0, 92 ), ( 148, 37, 69 ), ( 148, 74, 46 ), ( 148, 111, 23 ),

( 185, 0, 115 ), ( 185, 37, 92 ), ( 185, 74, 69 ), ( 185, 111, 46 ), ( 185, 148, 23 ),

( 222, 0, 138 ), ( 222, 37, 115 ), ( 222, 74, 92 ), ( 222, 111, 69 ), ( 222, 148, 46 ), ( 222, 185, 23 ),

( 259, 0, 161 ), ( 259, 37, 138 ), ( 259, 74, 115 ), ( 259, 111, 92 ), ( 259, 148, 69 ), ( 259, 185, 46 ), ( 259, 222, 23 ),

( 296, 0, 184 ), ( 296, 37, 161 ), ( 296, 74, 138 ), ( 296, 111, 115 ), ( 296, 148, 92 ), ( 296, 185, 69 ), ( 296, 222, 46 ), ( 296, 259, 23 ),

( 333, 0, 207 ), ( 333, 37, 184 ), ( 333, 74, 161 ), ( 333, 111, 138 ), ( 333, 148, 115 ), ( 333, 185, 92 ), ( 333, 222, 69 ), ( 333, 259, 46 ), ( 333, 296, 23 ),

( 370, 0, 230 ), ( 370, 37, 207 ), ( 370, 74, 184 ), ( 370, 111, 161 ), ( 370, 148, 138 ), ( 370, 185, 115 ), ( 370, 222, 92 ), ( 370, 259, 69 ), ( 370, 296, 46 ), ( 370, 333, 23 ),

( 407, 0, 253 ), ( 407, 37, 230 ), ( 407, 74, 207 ), ( 407, 111, 184 ), ( 407, 148, 161 ), ( 407, 185, 138 ), ( 407, 222, 115 ), ( 407, 259, 92 ), ( 407, 296, 69 ), ( 407, 333, 46 ), ( 407, 370, 23 ),

( 444, 0, 276 ), ( 444, 37, 253 ), ( 444, 74, 230 ), ( 444, 111, 207 ), ( 444, 148, 184 ), ( 444, 185, 161 ), ( 444, 222, 138 ), ( 444, 259, 115 ), ( 444, 296, 92 ), ( 444, 333, 69 ), ( 444, 370, 46 ), ( 444, 407, 23 ),

( 481, 0, 299 ), ( 481, 37, 276 ), ( 481, 74, 253 ), ( 481, 111, 230 ), ( 481, 148, 207 ), ( 481, 185, 184 ), ( 481, 222, 161 ), ( 481, 259, 138 ), ( 481, 296, 115 ), ( 481, 333, 92 ), ( 481, 370, 69 ), ( 481, 407, 46 ), ( 481, 444, 23 ),

( 518, 0, 322 ), ( 518, 37, 299 ), ( 518, 74, 276 ), ( 518, 111, 253 ), ( 518, 148, 230 ), ( 518, 185, 207 ), ( 518, 222, 184 ), ( 518, 259, 161 ), ( 518, 296, 138 ), ( 518, 333, 115 ), ( 518, 370, 92 ), ( 518, 407, 69 ), ( 518, 444, 46 ), ( 518, 481, 23 ),

...

}

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)