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

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

( 31, 0, 13 ),

( 62, 0, 26 ), ( 62, 31, 13 ),

( 93, 0, 39 ), ( 93, 31, 26 ), ( 93, 62, 13 ),

( 124, 0, 52 ), ( 124, 31, 39 ), ( 124, 62, 26 ), ( 124, 93, 13 ),

( 155, 0, 65 ), ( 155, 31, 52 ), ( 155, 62, 39 ), ( 155, 93, 26 ), ( 155, 124, 13 ),

( 186, 0, 78 ), ( 186, 31, 65 ), ( 186, 62, 52 ), ( 186, 93, 39 ), ( 186, 124, 26 ), ( 186, 155, 13 ),

( 217, 0, 91 ), ( 217, 31, 78 ), ( 217, 62, 65 ), ( 217, 93, 52 ), ( 217, 124, 39 ), ( 217, 155, 26 ), ( 217, 186, 13 ),

( 248, 0, 104 ), ( 248, 31, 91 ), ( 248, 62, 78 ), ( 248, 93, 65 ), ( 248, 124, 52 ), ( 248, 155, 39 ), ( 248, 186, 26 ), ( 248, 217, 13 ),

( 279, 0, 117 ), ( 279, 31, 104 ), ( 279, 62, 91 ), ( 279, 93, 78 ), ( 279, 124, 65 ), ( 279, 155, 52 ), ( 279, 186, 39 ), ( 279, 217, 26 ), ( 279, 248, 13 ),

( 310, 0, 130 ), ( 310, 31, 117 ), ( 310, 62, 104 ), ( 310, 93, 91 ), ( 310, 124, 78 ), ( 310, 155, 65 ), ( 310, 186, 52 ), ( 310, 217, 39 ), ( 310, 248, 26 ), ( 310, 279, 13 ),

( 341, 0, 143 ), ( 341, 31, 130 ), ( 341, 62, 117 ), ( 341, 93, 104 ), ( 341, 124, 91 ), ( 341, 155, 78 ), ( 341, 186, 65 ), ( 341, 217, 52 ), ( 341, 248, 39 ), ( 341, 279, 26 ), ( 341, 310, 13 ),

( 372, 0, 156 ), ( 372, 31, 143 ), ( 372, 62, 130 ), ( 372, 93, 117 ), ( 372, 124, 104 ), ( 372, 155, 91 ), ( 372, 186, 78 ), ( 372, 217, 65 ), ( 372, 248, 52 ), ( 372, 279, 39 ), ( 372, 310, 26 ), ( 372, 341, 13 ),

( 403, 0, 169 ), ( 403, 31, 156 ), ( 403, 62, 143 ), ( 403, 93, 130 ), ( 403, 124, 117 ), ( 403, 155, 104 ), ( 403, 186, 91 ), ( 403, 217, 78 ), ( 403, 248, 65 ), ( 403, 279, 52 ), ( 403, 310, 39 ), ( 403, 341, 26 ), ( 403, 372, 13 ),

( 434, 0, 182 ), ( 434, 31, 169 ), ( 434, 62, 156 ), ( 434, 93, 143 ), ( 434, 124, 130 ), ( 434, 155, 117 ), ( 434, 186, 104 ), ( 434, 217, 91 ), ( 434, 248, 78 ), ( 434, 279, 65 ), ( 434, 310, 52 ), ( 434, 341, 39 ), ( 434, 372, 26 ), ( 434, 403, 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)