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

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

( 18, 0, 7 ),

( 36, 0, 14 ), ( 36, 18, 7 ),

( 54, 0, 21 ), ( 54, 18, 14 ), ( 54, 36, 7 ),

( 72, 0, 28 ), ( 72, 18, 21 ), ( 72, 36, 14 ), ( 72, 54, 7 ),

( 90, 0, 35 ), ( 90, 18, 28 ), ( 90, 36, 21 ), ( 90, 54, 14 ), ( 90, 72, 7 ),

( 108, 0, 42 ), ( 108, 18, 35 ), ( 108, 36, 28 ), ( 108, 54, 21 ), ( 108, 72, 14 ), ( 108, 90, 7 ),

( 126, 0, 49 ), ( 126, 18, 42 ), ( 126, 36, 35 ), ( 126, 54, 28 ), ( 126, 72, 21 ), ( 126, 90, 14 ), ( 126, 108, 7 ),

( 144, 0, 56 ), ( 144, 18, 49 ), ( 144, 36, 42 ), ( 144, 54, 35 ), ( 144, 72, 28 ), ( 144, 90, 21 ), ( 144, 108, 14 ), ( 144, 126, 7 ),

( 162, 0, 63 ), ( 162, 18, 56 ), ( 162, 36, 49 ), ( 162, 54, 42 ), ( 162, 72, 35 ), ( 162, 90, 28 ), ( 162, 108, 21 ), ( 162, 126, 14 ), ( 162, 144, 7 ),

( 180, 0, 70 ), ( 180, 18, 63 ), ( 180, 36, 56 ), ( 180, 54, 49 ), ( 180, 72, 42 ), ( 180, 90, 35 ), ( 180, 108, 28 ), ( 180, 126, 21 ), ( 180, 144, 14 ), ( 180, 162, 7 ),

( 198, 0, 77 ), ( 198, 18, 70 ), ( 198, 36, 63 ), ( 198, 54, 56 ), ( 198, 72, 49 ), ( 198, 90, 42 ), ( 198, 108, 35 ), ( 198, 126, 28 ), ( 198, 144, 21 ), ( 198, 162, 14 ), ( 198, 180, 7 ),

( 216, 0, 84 ), ( 216, 18, 77 ), ( 216, 36, 70 ), ( 216, 54, 63 ), ( 216, 72, 56 ), ( 216, 90, 49 ), ( 216, 108, 42 ), ( 216, 126, 35 ), ( 216, 144, 28 ), ( 216, 162, 21 ), ( 216, 180, 14 ), ( 216, 198, 7 ),

( 234, 0, 91 ), ( 234, 18, 84 ), ( 234, 36, 77 ), ( 234, 54, 70 ), ( 234, 72, 63 ), ( 234, 90, 56 ), ( 234, 108, 49 ), ( 234, 126, 42 ), ( 234, 144, 35 ), ( 234, 162, 28 ), ( 234, 180, 21 ), ( 234, 198, 14 ), ( 234, 216, 7 ),

( 252, 0, 98 ), ( 252, 18, 91 ), ( 252, 36, 84 ), ( 252, 54, 77 ), ( 252, 72, 70 ), ( 252, 90, 63 ), ( 252, 108, 56 ), ( 252, 126, 49 ), ( 252, 144, 42 ), ( 252, 162, 35 ), ( 252, 180, 28 ), ( 252, 198, 21 ), ( 252, 216, 14 ), ( 252, 234, 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)