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

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

( 3, 0, 1 ),

( 6, 0, 2 ), ( 6, 3, 1 ),

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

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

( 15, 0, 5 ), ( 15, 3, 4 ), ( 15, 6, 3 ), ( 15, 9, 2 ), ( 15, 12, 1 ),

( 18, 0, 6 ), ( 18, 3, 5 ), ( 18, 6, 4 ), ( 18, 9, 3 ), ( 18, 12, 2 ), ( 18, 15, 1 ),

( 21, 0, 7 ), ( 21, 3, 6 ), ( 21, 6, 5 ), ( 21, 9, 4 ), ( 21, 12, 3 ), ( 21, 15, 2 ), ( 21, 18, 1 ),

( 24, 0, 8 ), ( 24, 3, 7 ), ( 24, 6, 6 ), ( 24, 9, 5 ), ( 24, 12, 4 ), ( 24, 15, 3 ), ( 24, 18, 2 ), ( 24, 21, 1 ),

( 27, 0, 9 ), ( 27, 3, 8 ), ( 27, 6, 7 ), ( 27, 9, 6 ), ( 27, 12, 5 ), ( 27, 15, 4 ), ( 27, 18, 3 ), ( 27, 21, 2 ), ( 27, 24, 1 ),

( 30, 0, 10 ), ( 30, 3, 9 ), ( 30, 6, 8 ), ( 30, 9, 7 ), ( 30, 12, 6 ), ( 30, 15, 5 ), ( 30, 18, 4 ), ( 30, 21, 3 ), ( 30, 24, 2 ), ( 30, 27, 1 ),

( 33, 0, 11 ), ( 33, 3, 10 ), ( 33, 6, 9 ), ( 33, 9, 8 ), ( 33, 12, 7 ), ( 33, 15, 6 ), ( 33, 18, 5 ), ( 33, 21, 4 ), ( 33, 24, 3 ), ( 33, 27, 2 ), ( 33, 30, 1 ),

( 36, 0, 12 ), ( 36, 3, 11 ), ( 36, 6, 10 ), ( 36, 9, 9 ), ( 36, 12, 8 ), ( 36, 15, 7 ), ( 36, 18, 6 ), ( 36, 21, 5 ), ( 36, 24, 4 ), ( 36, 27, 3 ), ( 36, 30, 2 ), ( 36, 33, 1 ),

( 39, 0, 13 ), ( 39, 3, 12 ), ( 39, 6, 11 ), ( 39, 9, 10 ), ( 39, 12, 9 ), ( 39, 15, 8 ), ( 39, 18, 7 ), ( 39, 21, 6 ), ( 39, 24, 5 ), ( 39, 27, 4 ), ( 39, 30, 3 ), ( 39, 33, 2 ), ( 39, 36, 1 ),

( 42, 0, 14 ), ( 42, 3, 13 ), ( 42, 6, 12 ), ( 42, 9, 11 ), ( 42, 12, 10 ), ( 42, 15, 9 ), ( 42, 18, 8 ), ( 42, 21, 7 ), ( 42, 24, 6 ), ( 42, 27, 5 ), ( 42, 30, 4 ), ( 42, 33, 3 ), ( 42, 36, 2 ), ( 42, 39, 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)