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

( 32, 0, 7 ),

( 64, 0, 14 ), ( 64, 32, 7 ),

( 96, 0, 21 ), ( 96, 32, 14 ), ( 96, 64, 7 ),

( 128, 0, 28 ), ( 128, 32, 21 ), ( 128, 64, 14 ), ( 128, 96, 7 ),

( 160, 0, 35 ), ( 160, 32, 28 ), ( 160, 64, 21 ), ( 160, 96, 14 ), ( 160, 128, 7 ),

( 192, 0, 42 ), ( 192, 32, 35 ), ( 192, 64, 28 ), ( 192, 96, 21 ), ( 192, 128, 14 ), ( 192, 160, 7 ),

( 224, 0, 49 ), ( 224, 32, 42 ), ( 224, 64, 35 ), ( 224, 96, 28 ), ( 224, 128, 21 ), ( 224, 160, 14 ), ( 224, 192, 7 ),

( 256, 0, 56 ), ( 256, 32, 49 ), ( 256, 64, 42 ), ( 256, 96, 35 ), ( 256, 128, 28 ), ( 256, 160, 21 ), ( 256, 192, 14 ), ( 256, 224, 7 ),

( 288, 0, 63 ), ( 288, 32, 56 ), ( 288, 64, 49 ), ( 288, 96, 42 ), ( 288, 128, 35 ), ( 288, 160, 28 ), ( 288, 192, 21 ), ( 288, 224, 14 ), ( 288, 256, 7 ),

( 320, 0, 70 ), ( 320, 32, 63 ), ( 320, 64, 56 ), ( 320, 96, 49 ), ( 320, 128, 42 ), ( 320, 160, 35 ), ( 320, 192, 28 ), ( 320, 224, 21 ), ( 320, 256, 14 ), ( 320, 288, 7 ),

( 352, 0, 77 ), ( 352, 32, 70 ), ( 352, 64, 63 ), ( 352, 96, 56 ), ( 352, 128, 49 ), ( 352, 160, 42 ), ( 352, 192, 35 ), ( 352, 224, 28 ), ( 352, 256, 21 ), ( 352, 288, 14 ), ( 352, 320, 7 ),

( 384, 0, 84 ), ( 384, 32, 77 ), ( 384, 64, 70 ), ( 384, 96, 63 ), ( 384, 128, 56 ), ( 384, 160, 49 ), ( 384, 192, 42 ), ( 384, 224, 35 ), ( 384, 256, 28 ), ( 384, 288, 21 ), ( 384, 320, 14 ), ( 384, 352, 7 ),

( 416, 0, 91 ), ( 416, 32, 84 ), ( 416, 64, 77 ), ( 416, 96, 70 ), ( 416, 128, 63 ), ( 416, 160, 56 ), ( 416, 192, 49 ), ( 416, 224, 42 ), ( 416, 256, 35 ), ( 416, 288, 28 ), ( 416, 320, 21 ), ( 416, 352, 14 ), ( 416, 384, 7 ),

( 448, 0, 98 ), ( 448, 32, 91 ), ( 448, 64, 84 ), ( 448, 96, 77 ), ( 448, 128, 70 ), ( 448, 160, 63 ), ( 448, 192, 56 ), ( 448, 224, 49 ), ( 448, 256, 42 ), ( 448, 288, 35 ), ( 448, 320, 28 ), ( 448, 352, 21 ), ( 448, 384, 14 ), ( 448, 416, 7 ),

...

}

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)