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

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

( 39, 0, 23 ),

( 78, 0, 46 ), ( 78, 39, 23 ),

( 117, 0, 69 ), ( 117, 39, 46 ), ( 117, 78, 23 ),

( 156, 0, 92 ), ( 156, 39, 69 ), ( 156, 78, 46 ), ( 156, 117, 23 ),

( 195, 0, 115 ), ( 195, 39, 92 ), ( 195, 78, 69 ), ( 195, 117, 46 ), ( 195, 156, 23 ),

( 234, 0, 138 ), ( 234, 39, 115 ), ( 234, 78, 92 ), ( 234, 117, 69 ), ( 234, 156, 46 ), ( 234, 195, 23 ),

( 273, 0, 161 ), ( 273, 39, 138 ), ( 273, 78, 115 ), ( 273, 117, 92 ), ( 273, 156, 69 ), ( 273, 195, 46 ), ( 273, 234, 23 ),

( 312, 0, 184 ), ( 312, 39, 161 ), ( 312, 78, 138 ), ( 312, 117, 115 ), ( 312, 156, 92 ), ( 312, 195, 69 ), ( 312, 234, 46 ), ( 312, 273, 23 ),

( 351, 0, 207 ), ( 351, 39, 184 ), ( 351, 78, 161 ), ( 351, 117, 138 ), ( 351, 156, 115 ), ( 351, 195, 92 ), ( 351, 234, 69 ), ( 351, 273, 46 ), ( 351, 312, 23 ),

( 390, 0, 230 ), ( 390, 39, 207 ), ( 390, 78, 184 ), ( 390, 117, 161 ), ( 390, 156, 138 ), ( 390, 195, 115 ), ( 390, 234, 92 ), ( 390, 273, 69 ), ( 390, 312, 46 ), ( 390, 351, 23 ),

( 429, 0, 253 ), ( 429, 39, 230 ), ( 429, 78, 207 ), ( 429, 117, 184 ), ( 429, 156, 161 ), ( 429, 195, 138 ), ( 429, 234, 115 ), ( 429, 273, 92 ), ( 429, 312, 69 ), ( 429, 351, 46 ), ( 429, 390, 23 ),

( 468, 0, 276 ), ( 468, 39, 253 ), ( 468, 78, 230 ), ( 468, 117, 207 ), ( 468, 156, 184 ), ( 468, 195, 161 ), ( 468, 234, 138 ), ( 468, 273, 115 ), ( 468, 312, 92 ), ( 468, 351, 69 ), ( 468, 390, 46 ), ( 468, 429, 23 ),

( 507, 0, 299 ), ( 507, 39, 276 ), ( 507, 78, 253 ), ( 507, 117, 230 ), ( 507, 156, 207 ), ( 507, 195, 184 ), ( 507, 234, 161 ), ( 507, 273, 138 ), ( 507, 312, 115 ), ( 507, 351, 92 ), ( 507, 390, 69 ), ( 507, 429, 46 ), ( 507, 468, 23 ),

( 546, 0, 322 ), ( 546, 39, 299 ), ( 546, 78, 276 ), ( 546, 117, 253 ), ( 546, 156, 230 ), ( 546, 195, 207 ), ( 546, 234, 184 ), ( 546, 273, 161 ), ( 546, 312, 138 ), ( 546, 351, 115 ), ( 546, 390, 92 ), ( 546, 429, 69 ), ( 546, 468, 46 ), ( 546, 507, 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)