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

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

( 17, 0, 9 ),

( 34, 0, 18 ), ( 34, 17, 9 ),

( 51, 0, 27 ), ( 51, 17, 18 ), ( 51, 34, 9 ),

( 68, 0, 36 ), ( 68, 17, 27 ), ( 68, 34, 18 ), ( 68, 51, 9 ),

( 85, 0, 45 ), ( 85, 17, 36 ), ( 85, 34, 27 ), ( 85, 51, 18 ), ( 85, 68, 9 ),

( 102, 0, 54 ), ( 102, 17, 45 ), ( 102, 34, 36 ), ( 102, 51, 27 ), ( 102, 68, 18 ), ( 102, 85, 9 ),

( 119, 0, 63 ), ( 119, 17, 54 ), ( 119, 34, 45 ), ( 119, 51, 36 ), ( 119, 68, 27 ), ( 119, 85, 18 ), ( 119, 102, 9 ),

( 136, 0, 72 ), ( 136, 17, 63 ), ( 136, 34, 54 ), ( 136, 51, 45 ), ( 136, 68, 36 ), ( 136, 85, 27 ), ( 136, 102, 18 ), ( 136, 119, 9 ),

( 153, 0, 81 ), ( 153, 17, 72 ), ( 153, 34, 63 ), ( 153, 51, 54 ), ( 153, 68, 45 ), ( 153, 85, 36 ), ( 153, 102, 27 ), ( 153, 119, 18 ), ( 153, 136, 9 ),

( 170, 0, 90 ), ( 170, 17, 81 ), ( 170, 34, 72 ), ( 170, 51, 63 ), ( 170, 68, 54 ), ( 170, 85, 45 ), ( 170, 102, 36 ), ( 170, 119, 27 ), ( 170, 136, 18 ), ( 170, 153, 9 ),

( 187, 0, 99 ), ( 187, 17, 90 ), ( 187, 34, 81 ), ( 187, 51, 72 ), ( 187, 68, 63 ), ( 187, 85, 54 ), ( 187, 102, 45 ), ( 187, 119, 36 ), ( 187, 136, 27 ), ( 187, 153, 18 ), ( 187, 170, 9 ),

( 204, 0, 108 ), ( 204, 17, 99 ), ( 204, 34, 90 ), ( 204, 51, 81 ), ( 204, 68, 72 ), ( 204, 85, 63 ), ( 204, 102, 54 ), ( 204, 119, 45 ), ( 204, 136, 36 ), ( 204, 153, 27 ), ( 204, 170, 18 ), ( 204, 187, 9 ),

( 221, 0, 117 ), ( 221, 17, 108 ), ( 221, 34, 99 ), ( 221, 51, 90 ), ( 221, 68, 81 ), ( 221, 85, 72 ), ( 221, 102, 63 ), ( 221, 119, 54 ), ( 221, 136, 45 ), ( 221, 153, 36 ), ( 221, 170, 27 ), ( 221, 187, 18 ), ( 221, 204, 9 ),

( 238, 0, 126 ), ( 238, 17, 117 ), ( 238, 34, 108 ), ( 238, 51, 99 ), ( 238, 68, 90 ), ( 238, 85, 81 ), ( 238, 102, 72 ), ( 238, 119, 63 ), ( 238, 136, 54 ), ( 238, 153, 45 ), ( 238, 170, 36 ), ( 238, 187, 27 ), ( 238, 204, 18 ), ( 238, 221, 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)