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

27/8 = (27-0)/8 = {

( 27, 0, 8 ),

( 54, 0, 16 ), ( 54, 27, 8 ),

( 81, 0, 24 ), ( 81, 27, 16 ), ( 81, 54, 8 ),

( 108, 0, 32 ), ( 108, 27, 24 ), ( 108, 54, 16 ), ( 108, 81, 8 ),

( 135, 0, 40 ), ( 135, 27, 32 ), ( 135, 54, 24 ), ( 135, 81, 16 ), ( 135, 108, 8 ),

( 162, 0, 48 ), ( 162, 27, 40 ), ( 162, 54, 32 ), ( 162, 81, 24 ), ( 162, 108, 16 ), ( 162, 135, 8 ),

( 189, 0, 56 ), ( 189, 27, 48 ), ( 189, 54, 40 ), ( 189, 81, 32 ), ( 189, 108, 24 ), ( 189, 135, 16 ), ( 189, 162, 8 ),

( 216, 0, 64 ), ( 216, 27, 56 ), ( 216, 54, 48 ), ( 216, 81, 40 ), ( 216, 108, 32 ), ( 216, 135, 24 ), ( 216, 162, 16 ), ( 216, 189, 8 ),

( 243, 0, 72 ), ( 243, 27, 64 ), ( 243, 54, 56 ), ( 243, 81, 48 ), ( 243, 108, 40 ), ( 243, 135, 32 ), ( 243, 162, 24 ), ( 243, 189, 16 ), ( 243, 216, 8 ),

( 270, 0, 80 ), ( 270, 27, 72 ), ( 270, 54, 64 ), ( 270, 81, 56 ), ( 270, 108, 48 ), ( 270, 135, 40 ), ( 270, 162, 32 ), ( 270, 189, 24 ), ( 270, 216, 16 ), ( 270, 243, 8 ),

( 297, 0, 88 ), ( 297, 27, 80 ), ( 297, 54, 72 ), ( 297, 81, 64 ), ( 297, 108, 56 ), ( 297, 135, 48 ), ( 297, 162, 40 ), ( 297, 189, 32 ), ( 297, 216, 24 ), ( 297, 243, 16 ), ( 297, 270, 8 ),

( 324, 0, 96 ), ( 324, 27, 88 ), ( 324, 54, 80 ), ( 324, 81, 72 ), ( 324, 108, 64 ), ( 324, 135, 56 ), ( 324, 162, 48 ), ( 324, 189, 40 ), ( 324, 216, 32 ), ( 324, 243, 24 ), ( 324, 270, 16 ), ( 324, 297, 8 ),

( 351, 0, 104 ), ( 351, 27, 96 ), ( 351, 54, 88 ), ( 351, 81, 80 ), ( 351, 108, 72 ), ( 351, 135, 64 ), ( 351, 162, 56 ), ( 351, 189, 48 ), ( 351, 216, 40 ), ( 351, 243, 32 ), ( 351, 270, 24 ), ( 351, 297, 16 ), ( 351, 324, 8 ),

( 378, 0, 112 ), ( 378, 27, 104 ), ( 378, 54, 96 ), ( 378, 81, 88 ), ( 378, 108, 80 ), ( 378, 135, 72 ), ( 378, 162, 64 ), ( 378, 189, 56 ), ( 378, 216, 48 ), ( 378, 243, 40 ), ( 378, 270, 32 ), ( 378, 297, 24 ), ( 378, 324, 16 ), ( 378, 351, 8 ),

...

}

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)