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

( 37, 0, 8 ),

( 74, 0, 16 ), ( 74, 37, 8 ),

( 111, 0, 24 ), ( 111, 37, 16 ), ( 111, 74, 8 ),

( 148, 0, 32 ), ( 148, 37, 24 ), ( 148, 74, 16 ), ( 148, 111, 8 ),

( 185, 0, 40 ), ( 185, 37, 32 ), ( 185, 74, 24 ), ( 185, 111, 16 ), ( 185, 148, 8 ),

( 222, 0, 48 ), ( 222, 37, 40 ), ( 222, 74, 32 ), ( 222, 111, 24 ), ( 222, 148, 16 ), ( 222, 185, 8 ),

( 259, 0, 56 ), ( 259, 37, 48 ), ( 259, 74, 40 ), ( 259, 111, 32 ), ( 259, 148, 24 ), ( 259, 185, 16 ), ( 259, 222, 8 ),

( 296, 0, 64 ), ( 296, 37, 56 ), ( 296, 74, 48 ), ( 296, 111, 40 ), ( 296, 148, 32 ), ( 296, 185, 24 ), ( 296, 222, 16 ), ( 296, 259, 8 ),

( 333, 0, 72 ), ( 333, 37, 64 ), ( 333, 74, 56 ), ( 333, 111, 48 ), ( 333, 148, 40 ), ( 333, 185, 32 ), ( 333, 222, 24 ), ( 333, 259, 16 ), ( 333, 296, 8 ),

( 370, 0, 80 ), ( 370, 37, 72 ), ( 370, 74, 64 ), ( 370, 111, 56 ), ( 370, 148, 48 ), ( 370, 185, 40 ), ( 370, 222, 32 ), ( 370, 259, 24 ), ( 370, 296, 16 ), ( 370, 333, 8 ),

( 407, 0, 88 ), ( 407, 37, 80 ), ( 407, 74, 72 ), ( 407, 111, 64 ), ( 407, 148, 56 ), ( 407, 185, 48 ), ( 407, 222, 40 ), ( 407, 259, 32 ), ( 407, 296, 24 ), ( 407, 333, 16 ), ( 407, 370, 8 ),

( 444, 0, 96 ), ( 444, 37, 88 ), ( 444, 74, 80 ), ( 444, 111, 72 ), ( 444, 148, 64 ), ( 444, 185, 56 ), ( 444, 222, 48 ), ( 444, 259, 40 ), ( 444, 296, 32 ), ( 444, 333, 24 ), ( 444, 370, 16 ), ( 444, 407, 8 ),

( 481, 0, 104 ), ( 481, 37, 96 ), ( 481, 74, 88 ), ( 481, 111, 80 ), ( 481, 148, 72 ), ( 481, 185, 64 ), ( 481, 222, 56 ), ( 481, 259, 48 ), ( 481, 296, 40 ), ( 481, 333, 32 ), ( 481, 370, 24 ), ( 481, 407, 16 ), ( 481, 444, 8 ),

( 518, 0, 112 ), ( 518, 37, 104 ), ( 518, 74, 96 ), ( 518, 111, 88 ), ( 518, 148, 80 ), ( 518, 185, 72 ), ( 518, 222, 64 ), ( 518, 259, 56 ), ( 518, 296, 48 ), ( 518, 333, 40 ), ( 518, 370, 32 ), ( 518, 407, 24 ), ( 518, 444, 16 ), ( 518, 481, 8 ),

...

}

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)