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

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

( 32, 0, 17 ),

( 64, 0, 34 ), ( 64, 32, 17 ),

( 96, 0, 51 ), ( 96, 32, 34 ), ( 96, 64, 17 ),

( 128, 0, 68 ), ( 128, 32, 51 ), ( 128, 64, 34 ), ( 128, 96, 17 ),

( 160, 0, 85 ), ( 160, 32, 68 ), ( 160, 64, 51 ), ( 160, 96, 34 ), ( 160, 128, 17 ),

( 192, 0, 102 ), ( 192, 32, 85 ), ( 192, 64, 68 ), ( 192, 96, 51 ), ( 192, 128, 34 ), ( 192, 160, 17 ),

( 224, 0, 119 ), ( 224, 32, 102 ), ( 224, 64, 85 ), ( 224, 96, 68 ), ( 224, 128, 51 ), ( 224, 160, 34 ), ( 224, 192, 17 ),

( 256, 0, 136 ), ( 256, 32, 119 ), ( 256, 64, 102 ), ( 256, 96, 85 ), ( 256, 128, 68 ), ( 256, 160, 51 ), ( 256, 192, 34 ), ( 256, 224, 17 ),

( 288, 0, 153 ), ( 288, 32, 136 ), ( 288, 64, 119 ), ( 288, 96, 102 ), ( 288, 128, 85 ), ( 288, 160, 68 ), ( 288, 192, 51 ), ( 288, 224, 34 ), ( 288, 256, 17 ),

( 320, 0, 170 ), ( 320, 32, 153 ), ( 320, 64, 136 ), ( 320, 96, 119 ), ( 320, 128, 102 ), ( 320, 160, 85 ), ( 320, 192, 68 ), ( 320, 224, 51 ), ( 320, 256, 34 ), ( 320, 288, 17 ),

( 352, 0, 187 ), ( 352, 32, 170 ), ( 352, 64, 153 ), ( 352, 96, 136 ), ( 352, 128, 119 ), ( 352, 160, 102 ), ( 352, 192, 85 ), ( 352, 224, 68 ), ( 352, 256, 51 ), ( 352, 288, 34 ), ( 352, 320, 17 ),

( 384, 0, 204 ), ( 384, 32, 187 ), ( 384, 64, 170 ), ( 384, 96, 153 ), ( 384, 128, 136 ), ( 384, 160, 119 ), ( 384, 192, 102 ), ( 384, 224, 85 ), ( 384, 256, 68 ), ( 384, 288, 51 ), ( 384, 320, 34 ), ( 384, 352, 17 ),

( 416, 0, 221 ), ( 416, 32, 204 ), ( 416, 64, 187 ), ( 416, 96, 170 ), ( 416, 128, 153 ), ( 416, 160, 136 ), ( 416, 192, 119 ), ( 416, 224, 102 ), ( 416, 256, 85 ), ( 416, 288, 68 ), ( 416, 320, 51 ), ( 416, 352, 34 ), ( 416, 384, 17 ),

( 448, 0, 238 ), ( 448, 32, 221 ), ( 448, 64, 204 ), ( 448, 96, 187 ), ( 448, 128, 170 ), ( 448, 160, 153 ), ( 448, 192, 136 ), ( 448, 224, 119 ), ( 448, 256, 102 ), ( 448, 288, 85 ), ( 448, 320, 68 ), ( 448, 352, 51 ), ( 448, 384, 34 ), ( 448, 416, 17 ),

...

}

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)