The rational number 8/3 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/3 = (8-0)/3 = {

( 8, 0, 3 ),

( 16, 0, 6 ), ( 16, 8, 3 ),

( 24, 0, 9 ), ( 24, 8, 6 ), ( 24, 16, 3 ),

( 32, 0, 12 ), ( 32, 8, 9 ), ( 32, 16, 6 ), ( 32, 24, 3 ),

( 40, 0, 15 ), ( 40, 8, 12 ), ( 40, 16, 9 ), ( 40, 24, 6 ), ( 40, 32, 3 ),

( 48, 0, 18 ), ( 48, 8, 15 ), ( 48, 16, 12 ), ( 48, 24, 9 ), ( 48, 32, 6 ), ( 48, 40, 3 ),

( 56, 0, 21 ), ( 56, 8, 18 ), ( 56, 16, 15 ), ( 56, 24, 12 ), ( 56, 32, 9 ), ( 56, 40, 6 ), ( 56, 48, 3 ),

( 64, 0, 24 ), ( 64, 8, 21 ), ( 64, 16, 18 ), ( 64, 24, 15 ), ( 64, 32, 12 ), ( 64, 40, 9 ), ( 64, 48, 6 ), ( 64, 56, 3 ),

( 72, 0, 27 ), ( 72, 8, 24 ), ( 72, 16, 21 ), ( 72, 24, 18 ), ( 72, 32, 15 ), ( 72, 40, 12 ), ( 72, 48, 9 ), ( 72, 56, 6 ), ( 72, 64, 3 ),

( 80, 0, 30 ), ( 80, 8, 27 ), ( 80, 16, 24 ), ( 80, 24, 21 ), ( 80, 32, 18 ), ( 80, 40, 15 ), ( 80, 48, 12 ), ( 80, 56, 9 ), ( 80, 64, 6 ), ( 80, 72, 3 ),

( 88, 0, 33 ), ( 88, 8, 30 ), ( 88, 16, 27 ), ( 88, 24, 24 ), ( 88, 32, 21 ), ( 88, 40, 18 ), ( 88, 48, 15 ), ( 88, 56, 12 ), ( 88, 64, 9 ), ( 88, 72, 6 ), ( 88, 80, 3 ),

( 96, 0, 36 ), ( 96, 8, 33 ), ( 96, 16, 30 ), ( 96, 24, 27 ), ( 96, 32, 24 ), ( 96, 40, 21 ), ( 96, 48, 18 ), ( 96, 56, 15 ), ( 96, 64, 12 ), ( 96, 72, 9 ), ( 96, 80, 6 ), ( 96, 88, 3 ),

( 104, 0, 39 ), ( 104, 8, 36 ), ( 104, 16, 33 ), ( 104, 24, 30 ), ( 104, 32, 27 ), ( 104, 40, 24 ), ( 104, 48, 21 ), ( 104, 56, 18 ), ( 104, 64, 15 ), ( 104, 72, 12 ), ( 104, 80, 9 ), ( 104, 88, 6 ), ( 104, 96, 3 ),

( 112, 0, 42 ), ( 112, 8, 39 ), ( 112, 16, 36 ), ( 112, 24, 33 ), ( 112, 32, 30 ), ( 112, 40, 27 ), ( 112, 48, 24 ), ( 112, 56, 21 ), ( 112, 64, 18 ), ( 112, 72, 15 ), ( 112, 80, 12 ), ( 112, 88, 9 ), ( 112, 96, 6 ), ( 112, 104, 3 ),

...

}

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)