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

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

( 8, 0, 5 ),

( 16, 0, 10 ), ( 16, 8, 5 ),

( 24, 0, 15 ), ( 24, 8, 10 ), ( 24, 16, 5 ),

( 32, 0, 20 ), ( 32, 8, 15 ), ( 32, 16, 10 ), ( 32, 24, 5 ),

( 40, 0, 25 ), ( 40, 8, 20 ), ( 40, 16, 15 ), ( 40, 24, 10 ), ( 40, 32, 5 ),

( 48, 0, 30 ), ( 48, 8, 25 ), ( 48, 16, 20 ), ( 48, 24, 15 ), ( 48, 32, 10 ), ( 48, 40, 5 ),

( 56, 0, 35 ), ( 56, 8, 30 ), ( 56, 16, 25 ), ( 56, 24, 20 ), ( 56, 32, 15 ), ( 56, 40, 10 ), ( 56, 48, 5 ),

( 64, 0, 40 ), ( 64, 8, 35 ), ( 64, 16, 30 ), ( 64, 24, 25 ), ( 64, 32, 20 ), ( 64, 40, 15 ), ( 64, 48, 10 ), ( 64, 56, 5 ),

( 72, 0, 45 ), ( 72, 8, 40 ), ( 72, 16, 35 ), ( 72, 24, 30 ), ( 72, 32, 25 ), ( 72, 40, 20 ), ( 72, 48, 15 ), ( 72, 56, 10 ), ( 72, 64, 5 ),

( 80, 0, 50 ), ( 80, 8, 45 ), ( 80, 16, 40 ), ( 80, 24, 35 ), ( 80, 32, 30 ), ( 80, 40, 25 ), ( 80, 48, 20 ), ( 80, 56, 15 ), ( 80, 64, 10 ), ( 80, 72, 5 ),

( 88, 0, 55 ), ( 88, 8, 50 ), ( 88, 16, 45 ), ( 88, 24, 40 ), ( 88, 32, 35 ), ( 88, 40, 30 ), ( 88, 48, 25 ), ( 88, 56, 20 ), ( 88, 64, 15 ), ( 88, 72, 10 ), ( 88, 80, 5 ),

( 96, 0, 60 ), ( 96, 8, 55 ), ( 96, 16, 50 ), ( 96, 24, 45 ), ( 96, 32, 40 ), ( 96, 40, 35 ), ( 96, 48, 30 ), ( 96, 56, 25 ), ( 96, 64, 20 ), ( 96, 72, 15 ), ( 96, 80, 10 ), ( 96, 88, 5 ),

( 104, 0, 65 ), ( 104, 8, 60 ), ( 104, 16, 55 ), ( 104, 24, 50 ), ( 104, 32, 45 ), ( 104, 40, 40 ), ( 104, 48, 35 ), ( 104, 56, 30 ), ( 104, 64, 25 ), ( 104, 72, 20 ), ( 104, 80, 15 ), ( 104, 88, 10 ), ( 104, 96, 5 ),

( 112, 0, 70 ), ( 112, 8, 65 ), ( 112, 16, 60 ), ( 112, 24, 55 ), ( 112, 32, 50 ), ( 112, 40, 45 ), ( 112, 48, 40 ), ( 112, 56, 35 ), ( 112, 64, 30 ), ( 112, 72, 25 ), ( 112, 80, 20 ), ( 112, 88, 15 ), ( 112, 96, 10 ), ( 112, 104, 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)