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

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

( 16, 0, 3 ),

( 32, 0, 6 ), ( 32, 16, 3 ),

( 48, 0, 9 ), ( 48, 16, 6 ), ( 48, 32, 3 ),

( 64, 0, 12 ), ( 64, 16, 9 ), ( 64, 32, 6 ), ( 64, 48, 3 ),

( 80, 0, 15 ), ( 80, 16, 12 ), ( 80, 32, 9 ), ( 80, 48, 6 ), ( 80, 64, 3 ),

( 96, 0, 18 ), ( 96, 16, 15 ), ( 96, 32, 12 ), ( 96, 48, 9 ), ( 96, 64, 6 ), ( 96, 80, 3 ),

( 112, 0, 21 ), ( 112, 16, 18 ), ( 112, 32, 15 ), ( 112, 48, 12 ), ( 112, 64, 9 ), ( 112, 80, 6 ), ( 112, 96, 3 ),

( 128, 0, 24 ), ( 128, 16, 21 ), ( 128, 32, 18 ), ( 128, 48, 15 ), ( 128, 64, 12 ), ( 128, 80, 9 ), ( 128, 96, 6 ), ( 128, 112, 3 ),

( 144, 0, 27 ), ( 144, 16, 24 ), ( 144, 32, 21 ), ( 144, 48, 18 ), ( 144, 64, 15 ), ( 144, 80, 12 ), ( 144, 96, 9 ), ( 144, 112, 6 ), ( 144, 128, 3 ),

( 160, 0, 30 ), ( 160, 16, 27 ), ( 160, 32, 24 ), ( 160, 48, 21 ), ( 160, 64, 18 ), ( 160, 80, 15 ), ( 160, 96, 12 ), ( 160, 112, 9 ), ( 160, 128, 6 ), ( 160, 144, 3 ),

( 176, 0, 33 ), ( 176, 16, 30 ), ( 176, 32, 27 ), ( 176, 48, 24 ), ( 176, 64, 21 ), ( 176, 80, 18 ), ( 176, 96, 15 ), ( 176, 112, 12 ), ( 176, 128, 9 ), ( 176, 144, 6 ), ( 176, 160, 3 ),

( 192, 0, 36 ), ( 192, 16, 33 ), ( 192, 32, 30 ), ( 192, 48, 27 ), ( 192, 64, 24 ), ( 192, 80, 21 ), ( 192, 96, 18 ), ( 192, 112, 15 ), ( 192, 128, 12 ), ( 192, 144, 9 ), ( 192, 160, 6 ), ( 192, 176, 3 ),

( 208, 0, 39 ), ( 208, 16, 36 ), ( 208, 32, 33 ), ( 208, 48, 30 ), ( 208, 64, 27 ), ( 208, 80, 24 ), ( 208, 96, 21 ), ( 208, 112, 18 ), ( 208, 128, 15 ), ( 208, 144, 12 ), ( 208, 160, 9 ), ( 208, 176, 6 ), ( 208, 192, 3 ),

( 224, 0, 42 ), ( 224, 16, 39 ), ( 224, 32, 36 ), ( 224, 48, 33 ), ( 224, 64, 30 ), ( 224, 80, 27 ), ( 224, 96, 24 ), ( 224, 112, 21 ), ( 224, 128, 18 ), ( 224, 144, 15 ), ( 224, 160, 12 ), ( 224, 176, 9 ), ( 224, 192, 6 ), ( 224, 208, 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)