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

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

( 37, 0, 16 ),

( 74, 0, 32 ), ( 74, 37, 16 ),

( 111, 0, 48 ), ( 111, 37, 32 ), ( 111, 74, 16 ),

( 148, 0, 64 ), ( 148, 37, 48 ), ( 148, 74, 32 ), ( 148, 111, 16 ),

( 185, 0, 80 ), ( 185, 37, 64 ), ( 185, 74, 48 ), ( 185, 111, 32 ), ( 185, 148, 16 ),

( 222, 0, 96 ), ( 222, 37, 80 ), ( 222, 74, 64 ), ( 222, 111, 48 ), ( 222, 148, 32 ), ( 222, 185, 16 ),

( 259, 0, 112 ), ( 259, 37, 96 ), ( 259, 74, 80 ), ( 259, 111, 64 ), ( 259, 148, 48 ), ( 259, 185, 32 ), ( 259, 222, 16 ),

( 296, 0, 128 ), ( 296, 37, 112 ), ( 296, 74, 96 ), ( 296, 111, 80 ), ( 296, 148, 64 ), ( 296, 185, 48 ), ( 296, 222, 32 ), ( 296, 259, 16 ),

( 333, 0, 144 ), ( 333, 37, 128 ), ( 333, 74, 112 ), ( 333, 111, 96 ), ( 333, 148, 80 ), ( 333, 185, 64 ), ( 333, 222, 48 ), ( 333, 259, 32 ), ( 333, 296, 16 ),

( 370, 0, 160 ), ( 370, 37, 144 ), ( 370, 74, 128 ), ( 370, 111, 112 ), ( 370, 148, 96 ), ( 370, 185, 80 ), ( 370, 222, 64 ), ( 370, 259, 48 ), ( 370, 296, 32 ), ( 370, 333, 16 ),

( 407, 0, 176 ), ( 407, 37, 160 ), ( 407, 74, 144 ), ( 407, 111, 128 ), ( 407, 148, 112 ), ( 407, 185, 96 ), ( 407, 222, 80 ), ( 407, 259, 64 ), ( 407, 296, 48 ), ( 407, 333, 32 ), ( 407, 370, 16 ),

( 444, 0, 192 ), ( 444, 37, 176 ), ( 444, 74, 160 ), ( 444, 111, 144 ), ( 444, 148, 128 ), ( 444, 185, 112 ), ( 444, 222, 96 ), ( 444, 259, 80 ), ( 444, 296, 64 ), ( 444, 333, 48 ), ( 444, 370, 32 ), ( 444, 407, 16 ),

( 481, 0, 208 ), ( 481, 37, 192 ), ( 481, 74, 176 ), ( 481, 111, 160 ), ( 481, 148, 144 ), ( 481, 185, 128 ), ( 481, 222, 112 ), ( 481, 259, 96 ), ( 481, 296, 80 ), ( 481, 333, 64 ), ( 481, 370, 48 ), ( 481, 407, 32 ), ( 481, 444, 16 ),

( 518, 0, 224 ), ( 518, 37, 208 ), ( 518, 74, 192 ), ( 518, 111, 176 ), ( 518, 148, 160 ), ( 518, 185, 144 ), ( 518, 222, 128 ), ( 518, 259, 112 ), ( 518, 296, 96 ), ( 518, 333, 80 ), ( 518, 370, 64 ), ( 518, 407, 48 ), ( 518, 444, 32 ), ( 518, 481, 16 ),

...

}

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)