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

18/1 = (18-0)/1 = {

( 18, 0, 1 ),

( 36, 0, 2 ), ( 36, 18, 1 ),

( 54, 0, 3 ), ( 54, 18, 2 ), ( 54, 36, 1 ),

( 72, 0, 4 ), ( 72, 18, 3 ), ( 72, 36, 2 ), ( 72, 54, 1 ),

( 90, 0, 5 ), ( 90, 18, 4 ), ( 90, 36, 3 ), ( 90, 54, 2 ), ( 90, 72, 1 ),

( 108, 0, 6 ), ( 108, 18, 5 ), ( 108, 36, 4 ), ( 108, 54, 3 ), ( 108, 72, 2 ), ( 108, 90, 1 ),

( 126, 0, 7 ), ( 126, 18, 6 ), ( 126, 36, 5 ), ( 126, 54, 4 ), ( 126, 72, 3 ), ( 126, 90, 2 ), ( 126, 108, 1 ),

( 144, 0, 8 ), ( 144, 18, 7 ), ( 144, 36, 6 ), ( 144, 54, 5 ), ( 144, 72, 4 ), ( 144, 90, 3 ), ( 144, 108, 2 ), ( 144, 126, 1 ),

( 162, 0, 9 ), ( 162, 18, 8 ), ( 162, 36, 7 ), ( 162, 54, 6 ), ( 162, 72, 5 ), ( 162, 90, 4 ), ( 162, 108, 3 ), ( 162, 126, 2 ), ( 162, 144, 1 ),

( 180, 0, 10 ), ( 180, 18, 9 ), ( 180, 36, 8 ), ( 180, 54, 7 ), ( 180, 72, 6 ), ( 180, 90, 5 ), ( 180, 108, 4 ), ( 180, 126, 3 ), ( 180, 144, 2 ), ( 180, 162, 1 ),

( 198, 0, 11 ), ( 198, 18, 10 ), ( 198, 36, 9 ), ( 198, 54, 8 ), ( 198, 72, 7 ), ( 198, 90, 6 ), ( 198, 108, 5 ), ( 198, 126, 4 ), ( 198, 144, 3 ), ( 198, 162, 2 ), ( 198, 180, 1 ),

( 216, 0, 12 ), ( 216, 18, 11 ), ( 216, 36, 10 ), ( 216, 54, 9 ), ( 216, 72, 8 ), ( 216, 90, 7 ), ( 216, 108, 6 ), ( 216, 126, 5 ), ( 216, 144, 4 ), ( 216, 162, 3 ), ( 216, 180, 2 ), ( 216, 198, 1 ),

( 234, 0, 13 ), ( 234, 18, 12 ), ( 234, 36, 11 ), ( 234, 54, 10 ), ( 234, 72, 9 ), ( 234, 90, 8 ), ( 234, 108, 7 ), ( 234, 126, 6 ), ( 234, 144, 5 ), ( 234, 162, 4 ), ( 234, 180, 3 ), ( 234, 198, 2 ), ( 234, 216, 1 ),

( 252, 0, 14 ), ( 252, 18, 13 ), ( 252, 36, 12 ), ( 252, 54, 11 ), ( 252, 72, 10 ), ( 252, 90, 9 ), ( 252, 108, 8 ), ( 252, 126, 7 ), ( 252, 144, 6 ), ( 252, 162, 5 ), ( 252, 180, 4 ), ( 252, 198, 3 ), ( 252, 216, 2 ), ( 252, 234, 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)