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

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

( 32, 0, 13 ),

( 64, 0, 26 ), ( 64, 32, 13 ),

( 96, 0, 39 ), ( 96, 32, 26 ), ( 96, 64, 13 ),

( 128, 0, 52 ), ( 128, 32, 39 ), ( 128, 64, 26 ), ( 128, 96, 13 ),

( 160, 0, 65 ), ( 160, 32, 52 ), ( 160, 64, 39 ), ( 160, 96, 26 ), ( 160, 128, 13 ),

( 192, 0, 78 ), ( 192, 32, 65 ), ( 192, 64, 52 ), ( 192, 96, 39 ), ( 192, 128, 26 ), ( 192, 160, 13 ),

( 224, 0, 91 ), ( 224, 32, 78 ), ( 224, 64, 65 ), ( 224, 96, 52 ), ( 224, 128, 39 ), ( 224, 160, 26 ), ( 224, 192, 13 ),

( 256, 0, 104 ), ( 256, 32, 91 ), ( 256, 64, 78 ), ( 256, 96, 65 ), ( 256, 128, 52 ), ( 256, 160, 39 ), ( 256, 192, 26 ), ( 256, 224, 13 ),

( 288, 0, 117 ), ( 288, 32, 104 ), ( 288, 64, 91 ), ( 288, 96, 78 ), ( 288, 128, 65 ), ( 288, 160, 52 ), ( 288, 192, 39 ), ( 288, 224, 26 ), ( 288, 256, 13 ),

( 320, 0, 130 ), ( 320, 32, 117 ), ( 320, 64, 104 ), ( 320, 96, 91 ), ( 320, 128, 78 ), ( 320, 160, 65 ), ( 320, 192, 52 ), ( 320, 224, 39 ), ( 320, 256, 26 ), ( 320, 288, 13 ),

( 352, 0, 143 ), ( 352, 32, 130 ), ( 352, 64, 117 ), ( 352, 96, 104 ), ( 352, 128, 91 ), ( 352, 160, 78 ), ( 352, 192, 65 ), ( 352, 224, 52 ), ( 352, 256, 39 ), ( 352, 288, 26 ), ( 352, 320, 13 ),

( 384, 0, 156 ), ( 384, 32, 143 ), ( 384, 64, 130 ), ( 384, 96, 117 ), ( 384, 128, 104 ), ( 384, 160, 91 ), ( 384, 192, 78 ), ( 384, 224, 65 ), ( 384, 256, 52 ), ( 384, 288, 39 ), ( 384, 320, 26 ), ( 384, 352, 13 ),

( 416, 0, 169 ), ( 416, 32, 156 ), ( 416, 64, 143 ), ( 416, 96, 130 ), ( 416, 128, 117 ), ( 416, 160, 104 ), ( 416, 192, 91 ), ( 416, 224, 78 ), ( 416, 256, 65 ), ( 416, 288, 52 ), ( 416, 320, 39 ), ( 416, 352, 26 ), ( 416, 384, 13 ),

( 448, 0, 182 ), ( 448, 32, 169 ), ( 448, 64, 156 ), ( 448, 96, 143 ), ( 448, 128, 130 ), ( 448, 160, 117 ), ( 448, 192, 104 ), ( 448, 224, 91 ), ( 448, 256, 78 ), ( 448, 288, 65 ), ( 448, 320, 52 ), ( 448, 352, 39 ), ( 448, 384, 26 ), ( 448, 416, 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)