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

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

( 31, 0, 9 ),

( 62, 0, 18 ), ( 62, 31, 9 ),

( 93, 0, 27 ), ( 93, 31, 18 ), ( 93, 62, 9 ),

( 124, 0, 36 ), ( 124, 31, 27 ), ( 124, 62, 18 ), ( 124, 93, 9 ),

( 155, 0, 45 ), ( 155, 31, 36 ), ( 155, 62, 27 ), ( 155, 93, 18 ), ( 155, 124, 9 ),

( 186, 0, 54 ), ( 186, 31, 45 ), ( 186, 62, 36 ), ( 186, 93, 27 ), ( 186, 124, 18 ), ( 186, 155, 9 ),

( 217, 0, 63 ), ( 217, 31, 54 ), ( 217, 62, 45 ), ( 217, 93, 36 ), ( 217, 124, 27 ), ( 217, 155, 18 ), ( 217, 186, 9 ),

( 248, 0, 72 ), ( 248, 31, 63 ), ( 248, 62, 54 ), ( 248, 93, 45 ), ( 248, 124, 36 ), ( 248, 155, 27 ), ( 248, 186, 18 ), ( 248, 217, 9 ),

( 279, 0, 81 ), ( 279, 31, 72 ), ( 279, 62, 63 ), ( 279, 93, 54 ), ( 279, 124, 45 ), ( 279, 155, 36 ), ( 279, 186, 27 ), ( 279, 217, 18 ), ( 279, 248, 9 ),

( 310, 0, 90 ), ( 310, 31, 81 ), ( 310, 62, 72 ), ( 310, 93, 63 ), ( 310, 124, 54 ), ( 310, 155, 45 ), ( 310, 186, 36 ), ( 310, 217, 27 ), ( 310, 248, 18 ), ( 310, 279, 9 ),

( 341, 0, 99 ), ( 341, 31, 90 ), ( 341, 62, 81 ), ( 341, 93, 72 ), ( 341, 124, 63 ), ( 341, 155, 54 ), ( 341, 186, 45 ), ( 341, 217, 36 ), ( 341, 248, 27 ), ( 341, 279, 18 ), ( 341, 310, 9 ),

( 372, 0, 108 ), ( 372, 31, 99 ), ( 372, 62, 90 ), ( 372, 93, 81 ), ( 372, 124, 72 ), ( 372, 155, 63 ), ( 372, 186, 54 ), ( 372, 217, 45 ), ( 372, 248, 36 ), ( 372, 279, 27 ), ( 372, 310, 18 ), ( 372, 341, 9 ),

( 403, 0, 117 ), ( 403, 31, 108 ), ( 403, 62, 99 ), ( 403, 93, 90 ), ( 403, 124, 81 ), ( 403, 155, 72 ), ( 403, 186, 63 ), ( 403, 217, 54 ), ( 403, 248, 45 ), ( 403, 279, 36 ), ( 403, 310, 27 ), ( 403, 341, 18 ), ( 403, 372, 9 ),

( 434, 0, 126 ), ( 434, 31, 117 ), ( 434, 62, 108 ), ( 434, 93, 99 ), ( 434, 124, 90 ), ( 434, 155, 81 ), ( 434, 186, 72 ), ( 434, 217, 63 ), ( 434, 248, 54 ), ( 434, 279, 45 ), ( 434, 310, 36 ), ( 434, 341, 27 ), ( 434, 372, 18 ), ( 434, 403, 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)