The rational number 32/5 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/5 = (32-0)/5 = {

( 32, 0, 5 ),

( 64, 0, 10 ), ( 64, 32, 5 ),

( 96, 0, 15 ), ( 96, 32, 10 ), ( 96, 64, 5 ),

( 128, 0, 20 ), ( 128, 32, 15 ), ( 128, 64, 10 ), ( 128, 96, 5 ),

( 160, 0, 25 ), ( 160, 32, 20 ), ( 160, 64, 15 ), ( 160, 96, 10 ), ( 160, 128, 5 ),

( 192, 0, 30 ), ( 192, 32, 25 ), ( 192, 64, 20 ), ( 192, 96, 15 ), ( 192, 128, 10 ), ( 192, 160, 5 ),

( 224, 0, 35 ), ( 224, 32, 30 ), ( 224, 64, 25 ), ( 224, 96, 20 ), ( 224, 128, 15 ), ( 224, 160, 10 ), ( 224, 192, 5 ),

( 256, 0, 40 ), ( 256, 32, 35 ), ( 256, 64, 30 ), ( 256, 96, 25 ), ( 256, 128, 20 ), ( 256, 160, 15 ), ( 256, 192, 10 ), ( 256, 224, 5 ),

( 288, 0, 45 ), ( 288, 32, 40 ), ( 288, 64, 35 ), ( 288, 96, 30 ), ( 288, 128, 25 ), ( 288, 160, 20 ), ( 288, 192, 15 ), ( 288, 224, 10 ), ( 288, 256, 5 ),

( 320, 0, 50 ), ( 320, 32, 45 ), ( 320, 64, 40 ), ( 320, 96, 35 ), ( 320, 128, 30 ), ( 320, 160, 25 ), ( 320, 192, 20 ), ( 320, 224, 15 ), ( 320, 256, 10 ), ( 320, 288, 5 ),

( 352, 0, 55 ), ( 352, 32, 50 ), ( 352, 64, 45 ), ( 352, 96, 40 ), ( 352, 128, 35 ), ( 352, 160, 30 ), ( 352, 192, 25 ), ( 352, 224, 20 ), ( 352, 256, 15 ), ( 352, 288, 10 ), ( 352, 320, 5 ),

( 384, 0, 60 ), ( 384, 32, 55 ), ( 384, 64, 50 ), ( 384, 96, 45 ), ( 384, 128, 40 ), ( 384, 160, 35 ), ( 384, 192, 30 ), ( 384, 224, 25 ), ( 384, 256, 20 ), ( 384, 288, 15 ), ( 384, 320, 10 ), ( 384, 352, 5 ),

( 416, 0, 65 ), ( 416, 32, 60 ), ( 416, 64, 55 ), ( 416, 96, 50 ), ( 416, 128, 45 ), ( 416, 160, 40 ), ( 416, 192, 35 ), ( 416, 224, 30 ), ( 416, 256, 25 ), ( 416, 288, 20 ), ( 416, 320, 15 ), ( 416, 352, 10 ), ( 416, 384, 5 ),

( 448, 0, 70 ), ( 448, 32, 65 ), ( 448, 64, 60 ), ( 448, 96, 55 ), ( 448, 128, 50 ), ( 448, 160, 45 ), ( 448, 192, 40 ), ( 448, 224, 35 ), ( 448, 256, 30 ), ( 448, 288, 25 ), ( 448, 320, 20 ), ( 448, 352, 15 ), ( 448, 384, 10 ), ( 448, 416, 5 ),

...

}

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)