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

38/23 = (38-0)/23 = {

( 38, 0, 23 ),

( 76, 0, 46 ), ( 76, 38, 23 ),

( 114, 0, 69 ), ( 114, 38, 46 ), ( 114, 76, 23 ),

( 152, 0, 92 ), ( 152, 38, 69 ), ( 152, 76, 46 ), ( 152, 114, 23 ),

( 190, 0, 115 ), ( 190, 38, 92 ), ( 190, 76, 69 ), ( 190, 114, 46 ), ( 190, 152, 23 ),

( 228, 0, 138 ), ( 228, 38, 115 ), ( 228, 76, 92 ), ( 228, 114, 69 ), ( 228, 152, 46 ), ( 228, 190, 23 ),

( 266, 0, 161 ), ( 266, 38, 138 ), ( 266, 76, 115 ), ( 266, 114, 92 ), ( 266, 152, 69 ), ( 266, 190, 46 ), ( 266, 228, 23 ),

( 304, 0, 184 ), ( 304, 38, 161 ), ( 304, 76, 138 ), ( 304, 114, 115 ), ( 304, 152, 92 ), ( 304, 190, 69 ), ( 304, 228, 46 ), ( 304, 266, 23 ),

( 342, 0, 207 ), ( 342, 38, 184 ), ( 342, 76, 161 ), ( 342, 114, 138 ), ( 342, 152, 115 ), ( 342, 190, 92 ), ( 342, 228, 69 ), ( 342, 266, 46 ), ( 342, 304, 23 ),

( 380, 0, 230 ), ( 380, 38, 207 ), ( 380, 76, 184 ), ( 380, 114, 161 ), ( 380, 152, 138 ), ( 380, 190, 115 ), ( 380, 228, 92 ), ( 380, 266, 69 ), ( 380, 304, 46 ), ( 380, 342, 23 ),

( 418, 0, 253 ), ( 418, 38, 230 ), ( 418, 76, 207 ), ( 418, 114, 184 ), ( 418, 152, 161 ), ( 418, 190, 138 ), ( 418, 228, 115 ), ( 418, 266, 92 ), ( 418, 304, 69 ), ( 418, 342, 46 ), ( 418, 380, 23 ),

( 456, 0, 276 ), ( 456, 38, 253 ), ( 456, 76, 230 ), ( 456, 114, 207 ), ( 456, 152, 184 ), ( 456, 190, 161 ), ( 456, 228, 138 ), ( 456, 266, 115 ), ( 456, 304, 92 ), ( 456, 342, 69 ), ( 456, 380, 46 ), ( 456, 418, 23 ),

( 494, 0, 299 ), ( 494, 38, 276 ), ( 494, 76, 253 ), ( 494, 114, 230 ), ( 494, 152, 207 ), ( 494, 190, 184 ), ( 494, 228, 161 ), ( 494, 266, 138 ), ( 494, 304, 115 ), ( 494, 342, 92 ), ( 494, 380, 69 ), ( 494, 418, 46 ), ( 494, 456, 23 ),

( 532, 0, 322 ), ( 532, 38, 299 ), ( 532, 76, 276 ), ( 532, 114, 253 ), ( 532, 152, 230 ), ( 532, 190, 207 ), ( 532, 228, 184 ), ( 532, 266, 161 ), ( 532, 304, 138 ), ( 532, 342, 115 ), ( 532, 380, 92 ), ( 532, 418, 69 ), ( 532, 456, 46 ), ( 532, 494, 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)