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

( 16, 0, 7 ),

( 32, 0, 14 ), ( 32, 16, 7 ),

( 48, 0, 21 ), ( 48, 16, 14 ), ( 48, 32, 7 ),

( 64, 0, 28 ), ( 64, 16, 21 ), ( 64, 32, 14 ), ( 64, 48, 7 ),

( 80, 0, 35 ), ( 80, 16, 28 ), ( 80, 32, 21 ), ( 80, 48, 14 ), ( 80, 64, 7 ),

( 96, 0, 42 ), ( 96, 16, 35 ), ( 96, 32, 28 ), ( 96, 48, 21 ), ( 96, 64, 14 ), ( 96, 80, 7 ),

( 112, 0, 49 ), ( 112, 16, 42 ), ( 112, 32, 35 ), ( 112, 48, 28 ), ( 112, 64, 21 ), ( 112, 80, 14 ), ( 112, 96, 7 ),

( 128, 0, 56 ), ( 128, 16, 49 ), ( 128, 32, 42 ), ( 128, 48, 35 ), ( 128, 64, 28 ), ( 128, 80, 21 ), ( 128, 96, 14 ), ( 128, 112, 7 ),

( 144, 0, 63 ), ( 144, 16, 56 ), ( 144, 32, 49 ), ( 144, 48, 42 ), ( 144, 64, 35 ), ( 144, 80, 28 ), ( 144, 96, 21 ), ( 144, 112, 14 ), ( 144, 128, 7 ),

( 160, 0, 70 ), ( 160, 16, 63 ), ( 160, 32, 56 ), ( 160, 48, 49 ), ( 160, 64, 42 ), ( 160, 80, 35 ), ( 160, 96, 28 ), ( 160, 112, 21 ), ( 160, 128, 14 ), ( 160, 144, 7 ),

( 176, 0, 77 ), ( 176, 16, 70 ), ( 176, 32, 63 ), ( 176, 48, 56 ), ( 176, 64, 49 ), ( 176, 80, 42 ), ( 176, 96, 35 ), ( 176, 112, 28 ), ( 176, 128, 21 ), ( 176, 144, 14 ), ( 176, 160, 7 ),

( 192, 0, 84 ), ( 192, 16, 77 ), ( 192, 32, 70 ), ( 192, 48, 63 ), ( 192, 64, 56 ), ( 192, 80, 49 ), ( 192, 96, 42 ), ( 192, 112, 35 ), ( 192, 128, 28 ), ( 192, 144, 21 ), ( 192, 160, 14 ), ( 192, 176, 7 ),

( 208, 0, 91 ), ( 208, 16, 84 ), ( 208, 32, 77 ), ( 208, 48, 70 ), ( 208, 64, 63 ), ( 208, 80, 56 ), ( 208, 96, 49 ), ( 208, 112, 42 ), ( 208, 128, 35 ), ( 208, 144, 28 ), ( 208, 160, 21 ), ( 208, 176, 14 ), ( 208, 192, 7 ),

( 224, 0, 98 ), ( 224, 16, 91 ), ( 224, 32, 84 ), ( 224, 48, 77 ), ( 224, 64, 70 ), ( 224, 80, 63 ), ( 224, 96, 56 ), ( 224, 112, 49 ), ( 224, 128, 42 ), ( 224, 144, 35 ), ( 224, 160, 28 ), ( 224, 176, 21 ), ( 224, 192, 14 ), ( 224, 208, 7 ),

...

}

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)