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

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

( 47, 0, 23 ),

( 94, 0, 46 ), ( 94, 47, 23 ),

( 141, 0, 69 ), ( 141, 47, 46 ), ( 141, 94, 23 ),

( 188, 0, 92 ), ( 188, 47, 69 ), ( 188, 94, 46 ), ( 188, 141, 23 ),

( 235, 0, 115 ), ( 235, 47, 92 ), ( 235, 94, 69 ), ( 235, 141, 46 ), ( 235, 188, 23 ),

( 282, 0, 138 ), ( 282, 47, 115 ), ( 282, 94, 92 ), ( 282, 141, 69 ), ( 282, 188, 46 ), ( 282, 235, 23 ),

( 329, 0, 161 ), ( 329, 47, 138 ), ( 329, 94, 115 ), ( 329, 141, 92 ), ( 329, 188, 69 ), ( 329, 235, 46 ), ( 329, 282, 23 ),

( 376, 0, 184 ), ( 376, 47, 161 ), ( 376, 94, 138 ), ( 376, 141, 115 ), ( 376, 188, 92 ), ( 376, 235, 69 ), ( 376, 282, 46 ), ( 376, 329, 23 ),

( 423, 0, 207 ), ( 423, 47, 184 ), ( 423, 94, 161 ), ( 423, 141, 138 ), ( 423, 188, 115 ), ( 423, 235, 92 ), ( 423, 282, 69 ), ( 423, 329, 46 ), ( 423, 376, 23 ),

( 470, 0, 230 ), ( 470, 47, 207 ), ( 470, 94, 184 ), ( 470, 141, 161 ), ( 470, 188, 138 ), ( 470, 235, 115 ), ( 470, 282, 92 ), ( 470, 329, 69 ), ( 470, 376, 46 ), ( 470, 423, 23 ),

( 517, 0, 253 ), ( 517, 47, 230 ), ( 517, 94, 207 ), ( 517, 141, 184 ), ( 517, 188, 161 ), ( 517, 235, 138 ), ( 517, 282, 115 ), ( 517, 329, 92 ), ( 517, 376, 69 ), ( 517, 423, 46 ), ( 517, 470, 23 ),

( 564, 0, 276 ), ( 564, 47, 253 ), ( 564, 94, 230 ), ( 564, 141, 207 ), ( 564, 188, 184 ), ( 564, 235, 161 ), ( 564, 282, 138 ), ( 564, 329, 115 ), ( 564, 376, 92 ), ( 564, 423, 69 ), ( 564, 470, 46 ), ( 564, 517, 23 ),

( 611, 0, 299 ), ( 611, 47, 276 ), ( 611, 94, 253 ), ( 611, 141, 230 ), ( 611, 188, 207 ), ( 611, 235, 184 ), ( 611, 282, 161 ), ( 611, 329, 138 ), ( 611, 376, 115 ), ( 611, 423, 92 ), ( 611, 470, 69 ), ( 611, 517, 46 ), ( 611, 564, 23 ),

( 658, 0, 322 ), ( 658, 47, 299 ), ( 658, 94, 276 ), ( 658, 141, 253 ), ( 658, 188, 230 ), ( 658, 235, 207 ), ( 658, 282, 184 ), ( 658, 329, 161 ), ( 658, 376, 138 ), ( 658, 423, 115 ), ( 658, 470, 92 ), ( 658, 517, 69 ), ( 658, 564, 46 ), ( 658, 611, 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)