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

9/5 = (9-0)/5 = {

( 9, 0, 5 ),

( 18, 0, 10 ), ( 18, 9, 5 ),

( 27, 0, 15 ), ( 27, 9, 10 ), ( 27, 18, 5 ),

( 36, 0, 20 ), ( 36, 9, 15 ), ( 36, 18, 10 ), ( 36, 27, 5 ),

( 45, 0, 25 ), ( 45, 9, 20 ), ( 45, 18, 15 ), ( 45, 27, 10 ), ( 45, 36, 5 ),

( 54, 0, 30 ), ( 54, 9, 25 ), ( 54, 18, 20 ), ( 54, 27, 15 ), ( 54, 36, 10 ), ( 54, 45, 5 ),

( 63, 0, 35 ), ( 63, 9, 30 ), ( 63, 18, 25 ), ( 63, 27, 20 ), ( 63, 36, 15 ), ( 63, 45, 10 ), ( 63, 54, 5 ),

( 72, 0, 40 ), ( 72, 9, 35 ), ( 72, 18, 30 ), ( 72, 27, 25 ), ( 72, 36, 20 ), ( 72, 45, 15 ), ( 72, 54, 10 ), ( 72, 63, 5 ),

( 81, 0, 45 ), ( 81, 9, 40 ), ( 81, 18, 35 ), ( 81, 27, 30 ), ( 81, 36, 25 ), ( 81, 45, 20 ), ( 81, 54, 15 ), ( 81, 63, 10 ), ( 81, 72, 5 ),

( 90, 0, 50 ), ( 90, 9, 45 ), ( 90, 18, 40 ), ( 90, 27, 35 ), ( 90, 36, 30 ), ( 90, 45, 25 ), ( 90, 54, 20 ), ( 90, 63, 15 ), ( 90, 72, 10 ), ( 90, 81, 5 ),

( 99, 0, 55 ), ( 99, 9, 50 ), ( 99, 18, 45 ), ( 99, 27, 40 ), ( 99, 36, 35 ), ( 99, 45, 30 ), ( 99, 54, 25 ), ( 99, 63, 20 ), ( 99, 72, 15 ), ( 99, 81, 10 ), ( 99, 90, 5 ),

( 108, 0, 60 ), ( 108, 9, 55 ), ( 108, 18, 50 ), ( 108, 27, 45 ), ( 108, 36, 40 ), ( 108, 45, 35 ), ( 108, 54, 30 ), ( 108, 63, 25 ), ( 108, 72, 20 ), ( 108, 81, 15 ), ( 108, 90, 10 ), ( 108, 99, 5 ),

( 117, 0, 65 ), ( 117, 9, 60 ), ( 117, 18, 55 ), ( 117, 27, 50 ), ( 117, 36, 45 ), ( 117, 45, 40 ), ( 117, 54, 35 ), ( 117, 63, 30 ), ( 117, 72, 25 ), ( 117, 81, 20 ), ( 117, 90, 15 ), ( 117, 99, 10 ), ( 117, 108, 5 ),

( 126, 0, 70 ), ( 126, 9, 65 ), ( 126, 18, 60 ), ( 126, 27, 55 ), ( 126, 36, 50 ), ( 126, 45, 45 ), ( 126, 54, 40 ), ( 126, 63, 35 ), ( 126, 72, 30 ), ( 126, 81, 25 ), ( 126, 90, 20 ), ( 126, 99, 15 ), ( 126, 108, 10 ), ( 126, 117, 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)