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

( 38, 0, 9 ),

( 76, 0, 18 ), ( 76, 38, 9 ),

( 114, 0, 27 ), ( 114, 38, 18 ), ( 114, 76, 9 ),

( 152, 0, 36 ), ( 152, 38, 27 ), ( 152, 76, 18 ), ( 152, 114, 9 ),

( 190, 0, 45 ), ( 190, 38, 36 ), ( 190, 76, 27 ), ( 190, 114, 18 ), ( 190, 152, 9 ),

( 228, 0, 54 ), ( 228, 38, 45 ), ( 228, 76, 36 ), ( 228, 114, 27 ), ( 228, 152, 18 ), ( 228, 190, 9 ),

( 266, 0, 63 ), ( 266, 38, 54 ), ( 266, 76, 45 ), ( 266, 114, 36 ), ( 266, 152, 27 ), ( 266, 190, 18 ), ( 266, 228, 9 ),

( 304, 0, 72 ), ( 304, 38, 63 ), ( 304, 76, 54 ), ( 304, 114, 45 ), ( 304, 152, 36 ), ( 304, 190, 27 ), ( 304, 228, 18 ), ( 304, 266, 9 ),

( 342, 0, 81 ), ( 342, 38, 72 ), ( 342, 76, 63 ), ( 342, 114, 54 ), ( 342, 152, 45 ), ( 342, 190, 36 ), ( 342, 228, 27 ), ( 342, 266, 18 ), ( 342, 304, 9 ),

( 380, 0, 90 ), ( 380, 38, 81 ), ( 380, 76, 72 ), ( 380, 114, 63 ), ( 380, 152, 54 ), ( 380, 190, 45 ), ( 380, 228, 36 ), ( 380, 266, 27 ), ( 380, 304, 18 ), ( 380, 342, 9 ),

( 418, 0, 99 ), ( 418, 38, 90 ), ( 418, 76, 81 ), ( 418, 114, 72 ), ( 418, 152, 63 ), ( 418, 190, 54 ), ( 418, 228, 45 ), ( 418, 266, 36 ), ( 418, 304, 27 ), ( 418, 342, 18 ), ( 418, 380, 9 ),

( 456, 0, 108 ), ( 456, 38, 99 ), ( 456, 76, 90 ), ( 456, 114, 81 ), ( 456, 152, 72 ), ( 456, 190, 63 ), ( 456, 228, 54 ), ( 456, 266, 45 ), ( 456, 304, 36 ), ( 456, 342, 27 ), ( 456, 380, 18 ), ( 456, 418, 9 ),

( 494, 0, 117 ), ( 494, 38, 108 ), ( 494, 76, 99 ), ( 494, 114, 90 ), ( 494, 152, 81 ), ( 494, 190, 72 ), ( 494, 228, 63 ), ( 494, 266, 54 ), ( 494, 304, 45 ), ( 494, 342, 36 ), ( 494, 380, 27 ), ( 494, 418, 18 ), ( 494, 456, 9 ),

( 532, 0, 126 ), ( 532, 38, 117 ), ( 532, 76, 108 ), ( 532, 114, 99 ), ( 532, 152, 90 ), ( 532, 190, 81 ), ( 532, 228, 72 ), ( 532, 266, 63 ), ( 532, 304, 54 ), ( 532, 342, 45 ), ( 532, 380, 36 ), ( 532, 418, 27 ), ( 532, 456, 18 ), ( 532, 494, 9 ),

...

}

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)