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

13/9 = (13-0)/9 = {

( 13, 0, 9 ),

( 26, 0, 18 ), ( 26, 13, 9 ),

( 39, 0, 27 ), ( 39, 13, 18 ), ( 39, 26, 9 ),

( 52, 0, 36 ), ( 52, 13, 27 ), ( 52, 26, 18 ), ( 52, 39, 9 ),

( 65, 0, 45 ), ( 65, 13, 36 ), ( 65, 26, 27 ), ( 65, 39, 18 ), ( 65, 52, 9 ),

( 78, 0, 54 ), ( 78, 13, 45 ), ( 78, 26, 36 ), ( 78, 39, 27 ), ( 78, 52, 18 ), ( 78, 65, 9 ),

( 91, 0, 63 ), ( 91, 13, 54 ), ( 91, 26, 45 ), ( 91, 39, 36 ), ( 91, 52, 27 ), ( 91, 65, 18 ), ( 91, 78, 9 ),

( 104, 0, 72 ), ( 104, 13, 63 ), ( 104, 26, 54 ), ( 104, 39, 45 ), ( 104, 52, 36 ), ( 104, 65, 27 ), ( 104, 78, 18 ), ( 104, 91, 9 ),

( 117, 0, 81 ), ( 117, 13, 72 ), ( 117, 26, 63 ), ( 117, 39, 54 ), ( 117, 52, 45 ), ( 117, 65, 36 ), ( 117, 78, 27 ), ( 117, 91, 18 ), ( 117, 104, 9 ),

( 130, 0, 90 ), ( 130, 13, 81 ), ( 130, 26, 72 ), ( 130, 39, 63 ), ( 130, 52, 54 ), ( 130, 65, 45 ), ( 130, 78, 36 ), ( 130, 91, 27 ), ( 130, 104, 18 ), ( 130, 117, 9 ),

( 143, 0, 99 ), ( 143, 13, 90 ), ( 143, 26, 81 ), ( 143, 39, 72 ), ( 143, 52, 63 ), ( 143, 65, 54 ), ( 143, 78, 45 ), ( 143, 91, 36 ), ( 143, 104, 27 ), ( 143, 117, 18 ), ( 143, 130, 9 ),

( 156, 0, 108 ), ( 156, 13, 99 ), ( 156, 26, 90 ), ( 156, 39, 81 ), ( 156, 52, 72 ), ( 156, 65, 63 ), ( 156, 78, 54 ), ( 156, 91, 45 ), ( 156, 104, 36 ), ( 156, 117, 27 ), ( 156, 130, 18 ), ( 156, 143, 9 ),

( 169, 0, 117 ), ( 169, 13, 108 ), ( 169, 26, 99 ), ( 169, 39, 90 ), ( 169, 52, 81 ), ( 169, 65, 72 ), ( 169, 78, 63 ), ( 169, 91, 54 ), ( 169, 104, 45 ), ( 169, 117, 36 ), ( 169, 130, 27 ), ( 169, 143, 18 ), ( 169, 156, 9 ),

( 182, 0, 126 ), ( 182, 13, 117 ), ( 182, 26, 108 ), ( 182, 39, 99 ), ( 182, 52, 90 ), ( 182, 65, 81 ), ( 182, 78, 72 ), ( 182, 91, 63 ), ( 182, 104, 54 ), ( 182, 117, 45 ), ( 182, 130, 36 ), ( 182, 143, 27 ), ( 182, 156, 18 ), ( 182, 169, 9 ),

...

}

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)