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

3/2 = (3-0)/2 = {

( 3, 0, 2 ),

( 6, 0, 4 ), ( 6, 3, 2 ),

( 9, 0, 6 ), ( 9, 3, 4 ), ( 9, 6, 2 ),

( 12, 0, 8 ), ( 12, 3, 6 ), ( 12, 6, 4 ), ( 12, 9, 2 ),

( 15, 0, 10 ), ( 15, 3, 8 ), ( 15, 6, 6 ), ( 15, 9, 4 ), ( 15, 12, 2 ),

( 18, 0, 12 ), ( 18, 3, 10 ), ( 18, 6, 8 ), ( 18, 9, 6 ), ( 18, 12, 4 ), ( 18, 15, 2 ),

( 21, 0, 14 ), ( 21, 3, 12 ), ( 21, 6, 10 ), ( 21, 9, 8 ), ( 21, 12, 6 ), ( 21, 15, 4 ), ( 21, 18, 2 ),

( 24, 0, 16 ), ( 24, 3, 14 ), ( 24, 6, 12 ), ( 24, 9, 10 ), ( 24, 12, 8 ), ( 24, 15, 6 ), ( 24, 18, 4 ), ( 24, 21, 2 ),

( 27, 0, 18 ), ( 27, 3, 16 ), ( 27, 6, 14 ), ( 27, 9, 12 ), ( 27, 12, 10 ), ( 27, 15, 8 ), ( 27, 18, 6 ), ( 27, 21, 4 ), ( 27, 24, 2 ),

( 30, 0, 20 ), ( 30, 3, 18 ), ( 30, 6, 16 ), ( 30, 9, 14 ), ( 30, 12, 12 ), ( 30, 15, 10 ), ( 30, 18, 8 ), ( 30, 21, 6 ), ( 30, 24, 4 ), ( 30, 27, 2 ),

( 33, 0, 22 ), ( 33, 3, 20 ), ( 33, 6, 18 ), ( 33, 9, 16 ), ( 33, 12, 14 ), ( 33, 15, 12 ), ( 33, 18, 10 ), ( 33, 21, 8 ), ( 33, 24, 6 ), ( 33, 27, 4 ), ( 33, 30, 2 ),

( 36, 0, 24 ), ( 36, 3, 22 ), ( 36, 6, 20 ), ( 36, 9, 18 ), ( 36, 12, 16 ), ( 36, 15, 14 ), ( 36, 18, 12 ), ( 36, 21, 10 ), ( 36, 24, 8 ), ( 36, 27, 6 ), ( 36, 30, 4 ), ( 36, 33, 2 ),

( 39, 0, 26 ), ( 39, 3, 24 ), ( 39, 6, 22 ), ( 39, 9, 20 ), ( 39, 12, 18 ), ( 39, 15, 16 ), ( 39, 18, 14 ), ( 39, 21, 12 ), ( 39, 24, 10 ), ( 39, 27, 8 ), ( 39, 30, 6 ), ( 39, 33, 4 ), ( 39, 36, 2 ),

( 42, 0, 28 ), ( 42, 3, 26 ), ( 42, 6, 24 ), ( 42, 9, 22 ), ( 42, 12, 20 ), ( 42, 15, 18 ), ( 42, 18, 16 ), ( 42, 21, 14 ), ( 42, 24, 12 ), ( 42, 27, 10 ), ( 42, 30, 8 ), ( 42, 33, 6 ), ( 42, 36, 4 ), ( 42, 39, 2 ),

...

}

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)