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

( 38, 0, 1 ),

( 76, 0, 2 ), ( 76, 38, 1 ),

( 114, 0, 3 ), ( 114, 38, 2 ), ( 114, 76, 1 ),

( 152, 0, 4 ), ( 152, 38, 3 ), ( 152, 76, 2 ), ( 152, 114, 1 ),

( 190, 0, 5 ), ( 190, 38, 4 ), ( 190, 76, 3 ), ( 190, 114, 2 ), ( 190, 152, 1 ),

( 228, 0, 6 ), ( 228, 38, 5 ), ( 228, 76, 4 ), ( 228, 114, 3 ), ( 228, 152, 2 ), ( 228, 190, 1 ),

( 266, 0, 7 ), ( 266, 38, 6 ), ( 266, 76, 5 ), ( 266, 114, 4 ), ( 266, 152, 3 ), ( 266, 190, 2 ), ( 266, 228, 1 ),

( 304, 0, 8 ), ( 304, 38, 7 ), ( 304, 76, 6 ), ( 304, 114, 5 ), ( 304, 152, 4 ), ( 304, 190, 3 ), ( 304, 228, 2 ), ( 304, 266, 1 ),

( 342, 0, 9 ), ( 342, 38, 8 ), ( 342, 76, 7 ), ( 342, 114, 6 ), ( 342, 152, 5 ), ( 342, 190, 4 ), ( 342, 228, 3 ), ( 342, 266, 2 ), ( 342, 304, 1 ),

( 380, 0, 10 ), ( 380, 38, 9 ), ( 380, 76, 8 ), ( 380, 114, 7 ), ( 380, 152, 6 ), ( 380, 190, 5 ), ( 380, 228, 4 ), ( 380, 266, 3 ), ( 380, 304, 2 ), ( 380, 342, 1 ),

( 418, 0, 11 ), ( 418, 38, 10 ), ( 418, 76, 9 ), ( 418, 114, 8 ), ( 418, 152, 7 ), ( 418, 190, 6 ), ( 418, 228, 5 ), ( 418, 266, 4 ), ( 418, 304, 3 ), ( 418, 342, 2 ), ( 418, 380, 1 ),

( 456, 0, 12 ), ( 456, 38, 11 ), ( 456, 76, 10 ), ( 456, 114, 9 ), ( 456, 152, 8 ), ( 456, 190, 7 ), ( 456, 228, 6 ), ( 456, 266, 5 ), ( 456, 304, 4 ), ( 456, 342, 3 ), ( 456, 380, 2 ), ( 456, 418, 1 ),

( 494, 0, 13 ), ( 494, 38, 12 ), ( 494, 76, 11 ), ( 494, 114, 10 ), ( 494, 152, 9 ), ( 494, 190, 8 ), ( 494, 228, 7 ), ( 494, 266, 6 ), ( 494, 304, 5 ), ( 494, 342, 4 ), ( 494, 380, 3 ), ( 494, 418, 2 ), ( 494, 456, 1 ),

( 532, 0, 14 ), ( 532, 38, 13 ), ( 532, 76, 12 ), ( 532, 114, 11 ), ( 532, 152, 10 ), ( 532, 190, 9 ), ( 532, 228, 8 ), ( 532, 266, 7 ), ( 532, 304, 6 ), ( 532, 342, 5 ), ( 532, 380, 4 ), ( 532, 418, 3 ), ( 532, 456, 2 ), ( 532, 494, 1 ),

...

}

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)