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

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

( 42, 0, 23 ),

( 84, 0, 46 ), ( 84, 42, 23 ),

( 126, 0, 69 ), ( 126, 42, 46 ), ( 126, 84, 23 ),

( 168, 0, 92 ), ( 168, 42, 69 ), ( 168, 84, 46 ), ( 168, 126, 23 ),

( 210, 0, 115 ), ( 210, 42, 92 ), ( 210, 84, 69 ), ( 210, 126, 46 ), ( 210, 168, 23 ),

( 252, 0, 138 ), ( 252, 42, 115 ), ( 252, 84, 92 ), ( 252, 126, 69 ), ( 252, 168, 46 ), ( 252, 210, 23 ),

( 294, 0, 161 ), ( 294, 42, 138 ), ( 294, 84, 115 ), ( 294, 126, 92 ), ( 294, 168, 69 ), ( 294, 210, 46 ), ( 294, 252, 23 ),

( 336, 0, 184 ), ( 336, 42, 161 ), ( 336, 84, 138 ), ( 336, 126, 115 ), ( 336, 168, 92 ), ( 336, 210, 69 ), ( 336, 252, 46 ), ( 336, 294, 23 ),

( 378, 0, 207 ), ( 378, 42, 184 ), ( 378, 84, 161 ), ( 378, 126, 138 ), ( 378, 168, 115 ), ( 378, 210, 92 ), ( 378, 252, 69 ), ( 378, 294, 46 ), ( 378, 336, 23 ),

( 420, 0, 230 ), ( 420, 42, 207 ), ( 420, 84, 184 ), ( 420, 126, 161 ), ( 420, 168, 138 ), ( 420, 210, 115 ), ( 420, 252, 92 ), ( 420, 294, 69 ), ( 420, 336, 46 ), ( 420, 378, 23 ),

( 462, 0, 253 ), ( 462, 42, 230 ), ( 462, 84, 207 ), ( 462, 126, 184 ), ( 462, 168, 161 ), ( 462, 210, 138 ), ( 462, 252, 115 ), ( 462, 294, 92 ), ( 462, 336, 69 ), ( 462, 378, 46 ), ( 462, 420, 23 ),

( 504, 0, 276 ), ( 504, 42, 253 ), ( 504, 84, 230 ), ( 504, 126, 207 ), ( 504, 168, 184 ), ( 504, 210, 161 ), ( 504, 252, 138 ), ( 504, 294, 115 ), ( 504, 336, 92 ), ( 504, 378, 69 ), ( 504, 420, 46 ), ( 504, 462, 23 ),

( 546, 0, 299 ), ( 546, 42, 276 ), ( 546, 84, 253 ), ( 546, 126, 230 ), ( 546, 168, 207 ), ( 546, 210, 184 ), ( 546, 252, 161 ), ( 546, 294, 138 ), ( 546, 336, 115 ), ( 546, 378, 92 ), ( 546, 420, 69 ), ( 546, 462, 46 ), ( 546, 504, 23 ),

( 588, 0, 322 ), ( 588, 42, 299 ), ( 588, 84, 276 ), ( 588, 126, 253 ), ( 588, 168, 230 ), ( 588, 210, 207 ), ( 588, 252, 184 ), ( 588, 294, 161 ), ( 588, 336, 138 ), ( 588, 378, 115 ), ( 588, 420, 92 ), ( 588, 462, 69 ), ( 588, 504, 46 ), ( 588, 546, 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)