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

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

( 34, 0, 13 ),

( 68, 0, 26 ), ( 68, 34, 13 ),

( 102, 0, 39 ), ( 102, 34, 26 ), ( 102, 68, 13 ),

( 136, 0, 52 ), ( 136, 34, 39 ), ( 136, 68, 26 ), ( 136, 102, 13 ),

( 170, 0, 65 ), ( 170, 34, 52 ), ( 170, 68, 39 ), ( 170, 102, 26 ), ( 170, 136, 13 ),

( 204, 0, 78 ), ( 204, 34, 65 ), ( 204, 68, 52 ), ( 204, 102, 39 ), ( 204, 136, 26 ), ( 204, 170, 13 ),

( 238, 0, 91 ), ( 238, 34, 78 ), ( 238, 68, 65 ), ( 238, 102, 52 ), ( 238, 136, 39 ), ( 238, 170, 26 ), ( 238, 204, 13 ),

( 272, 0, 104 ), ( 272, 34, 91 ), ( 272, 68, 78 ), ( 272, 102, 65 ), ( 272, 136, 52 ), ( 272, 170, 39 ), ( 272, 204, 26 ), ( 272, 238, 13 ),

( 306, 0, 117 ), ( 306, 34, 104 ), ( 306, 68, 91 ), ( 306, 102, 78 ), ( 306, 136, 65 ), ( 306, 170, 52 ), ( 306, 204, 39 ), ( 306, 238, 26 ), ( 306, 272, 13 ),

( 340, 0, 130 ), ( 340, 34, 117 ), ( 340, 68, 104 ), ( 340, 102, 91 ), ( 340, 136, 78 ), ( 340, 170, 65 ), ( 340, 204, 52 ), ( 340, 238, 39 ), ( 340, 272, 26 ), ( 340, 306, 13 ),

( 374, 0, 143 ), ( 374, 34, 130 ), ( 374, 68, 117 ), ( 374, 102, 104 ), ( 374, 136, 91 ), ( 374, 170, 78 ), ( 374, 204, 65 ), ( 374, 238, 52 ), ( 374, 272, 39 ), ( 374, 306, 26 ), ( 374, 340, 13 ),

( 408, 0, 156 ), ( 408, 34, 143 ), ( 408, 68, 130 ), ( 408, 102, 117 ), ( 408, 136, 104 ), ( 408, 170, 91 ), ( 408, 204, 78 ), ( 408, 238, 65 ), ( 408, 272, 52 ), ( 408, 306, 39 ), ( 408, 340, 26 ), ( 408, 374, 13 ),

( 442, 0, 169 ), ( 442, 34, 156 ), ( 442, 68, 143 ), ( 442, 102, 130 ), ( 442, 136, 117 ), ( 442, 170, 104 ), ( 442, 204, 91 ), ( 442, 238, 78 ), ( 442, 272, 65 ), ( 442, 306, 52 ), ( 442, 340, 39 ), ( 442, 374, 26 ), ( 442, 408, 13 ),

( 476, 0, 182 ), ( 476, 34, 169 ), ( 476, 68, 156 ), ( 476, 102, 143 ), ( 476, 136, 130 ), ( 476, 170, 117 ), ( 476, 204, 104 ), ( 476, 238, 91 ), ( 476, 272, 78 ), ( 476, 306, 65 ), ( 476, 340, 52 ), ( 476, 374, 39 ), ( 476, 408, 26 ), ( 476, 442, 13 ),

...

}

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)