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

33/7 = (33-0)/7 = {

( 33, 0, 7 ),

( 66, 0, 14 ), ( 66, 33, 7 ),

( 99, 0, 21 ), ( 99, 33, 14 ), ( 99, 66, 7 ),

( 132, 0, 28 ), ( 132, 33, 21 ), ( 132, 66, 14 ), ( 132, 99, 7 ),

( 165, 0, 35 ), ( 165, 33, 28 ), ( 165, 66, 21 ), ( 165, 99, 14 ), ( 165, 132, 7 ),

( 198, 0, 42 ), ( 198, 33, 35 ), ( 198, 66, 28 ), ( 198, 99, 21 ), ( 198, 132, 14 ), ( 198, 165, 7 ),

( 231, 0, 49 ), ( 231, 33, 42 ), ( 231, 66, 35 ), ( 231, 99, 28 ), ( 231, 132, 21 ), ( 231, 165, 14 ), ( 231, 198, 7 ),

( 264, 0, 56 ), ( 264, 33, 49 ), ( 264, 66, 42 ), ( 264, 99, 35 ), ( 264, 132, 28 ), ( 264, 165, 21 ), ( 264, 198, 14 ), ( 264, 231, 7 ),

( 297, 0, 63 ), ( 297, 33, 56 ), ( 297, 66, 49 ), ( 297, 99, 42 ), ( 297, 132, 35 ), ( 297, 165, 28 ), ( 297, 198, 21 ), ( 297, 231, 14 ), ( 297, 264, 7 ),

( 330, 0, 70 ), ( 330, 33, 63 ), ( 330, 66, 56 ), ( 330, 99, 49 ), ( 330, 132, 42 ), ( 330, 165, 35 ), ( 330, 198, 28 ), ( 330, 231, 21 ), ( 330, 264, 14 ), ( 330, 297, 7 ),

( 363, 0, 77 ), ( 363, 33, 70 ), ( 363, 66, 63 ), ( 363, 99, 56 ), ( 363, 132, 49 ), ( 363, 165, 42 ), ( 363, 198, 35 ), ( 363, 231, 28 ), ( 363, 264, 21 ), ( 363, 297, 14 ), ( 363, 330, 7 ),

( 396, 0, 84 ), ( 396, 33, 77 ), ( 396, 66, 70 ), ( 396, 99, 63 ), ( 396, 132, 56 ), ( 396, 165, 49 ), ( 396, 198, 42 ), ( 396, 231, 35 ), ( 396, 264, 28 ), ( 396, 297, 21 ), ( 396, 330, 14 ), ( 396, 363, 7 ),

( 429, 0, 91 ), ( 429, 33, 84 ), ( 429, 66, 77 ), ( 429, 99, 70 ), ( 429, 132, 63 ), ( 429, 165, 56 ), ( 429, 198, 49 ), ( 429, 231, 42 ), ( 429, 264, 35 ), ( 429, 297, 28 ), ( 429, 330, 21 ), ( 429, 363, 14 ), ( 429, 396, 7 ),

( 462, 0, 98 ), ( 462, 33, 91 ), ( 462, 66, 84 ), ( 462, 99, 77 ), ( 462, 132, 70 ), ( 462, 165, 63 ), ( 462, 198, 56 ), ( 462, 231, 49 ), ( 462, 264, 42 ), ( 462, 297, 35 ), ( 462, 330, 28 ), ( 462, 363, 21 ), ( 462, 396, 14 ), ( 462, 429, 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)