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

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

( 16, 0, 5 ),

( 32, 0, 10 ), ( 32, 16, 5 ),

( 48, 0, 15 ), ( 48, 16, 10 ), ( 48, 32, 5 ),

( 64, 0, 20 ), ( 64, 16, 15 ), ( 64, 32, 10 ), ( 64, 48, 5 ),

( 80, 0, 25 ), ( 80, 16, 20 ), ( 80, 32, 15 ), ( 80, 48, 10 ), ( 80, 64, 5 ),

( 96, 0, 30 ), ( 96, 16, 25 ), ( 96, 32, 20 ), ( 96, 48, 15 ), ( 96, 64, 10 ), ( 96, 80, 5 ),

( 112, 0, 35 ), ( 112, 16, 30 ), ( 112, 32, 25 ), ( 112, 48, 20 ), ( 112, 64, 15 ), ( 112, 80, 10 ), ( 112, 96, 5 ),

( 128, 0, 40 ), ( 128, 16, 35 ), ( 128, 32, 30 ), ( 128, 48, 25 ), ( 128, 64, 20 ), ( 128, 80, 15 ), ( 128, 96, 10 ), ( 128, 112, 5 ),

( 144, 0, 45 ), ( 144, 16, 40 ), ( 144, 32, 35 ), ( 144, 48, 30 ), ( 144, 64, 25 ), ( 144, 80, 20 ), ( 144, 96, 15 ), ( 144, 112, 10 ), ( 144, 128, 5 ),

( 160, 0, 50 ), ( 160, 16, 45 ), ( 160, 32, 40 ), ( 160, 48, 35 ), ( 160, 64, 30 ), ( 160, 80, 25 ), ( 160, 96, 20 ), ( 160, 112, 15 ), ( 160, 128, 10 ), ( 160, 144, 5 ),

( 176, 0, 55 ), ( 176, 16, 50 ), ( 176, 32, 45 ), ( 176, 48, 40 ), ( 176, 64, 35 ), ( 176, 80, 30 ), ( 176, 96, 25 ), ( 176, 112, 20 ), ( 176, 128, 15 ), ( 176, 144, 10 ), ( 176, 160, 5 ),

( 192, 0, 60 ), ( 192, 16, 55 ), ( 192, 32, 50 ), ( 192, 48, 45 ), ( 192, 64, 40 ), ( 192, 80, 35 ), ( 192, 96, 30 ), ( 192, 112, 25 ), ( 192, 128, 20 ), ( 192, 144, 15 ), ( 192, 160, 10 ), ( 192, 176, 5 ),

( 208, 0, 65 ), ( 208, 16, 60 ), ( 208, 32, 55 ), ( 208, 48, 50 ), ( 208, 64, 45 ), ( 208, 80, 40 ), ( 208, 96, 35 ), ( 208, 112, 30 ), ( 208, 128, 25 ), ( 208, 144, 20 ), ( 208, 160, 15 ), ( 208, 176, 10 ), ( 208, 192, 5 ),

( 224, 0, 70 ), ( 224, 16, 65 ), ( 224, 32, 60 ), ( 224, 48, 55 ), ( 224, 64, 50 ), ( 224, 80, 45 ), ( 224, 96, 40 ), ( 224, 112, 35 ), ( 224, 128, 30 ), ( 224, 144, 25 ), ( 224, 160, 20 ), ( 224, 176, 15 ), ( 224, 192, 10 ), ( 224, 208, 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)