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

( 37, 0, 22 ),

( 74, 0, 44 ), ( 74, 37, 22 ),

( 111, 0, 66 ), ( 111, 37, 44 ), ( 111, 74, 22 ),

( 148, 0, 88 ), ( 148, 37, 66 ), ( 148, 74, 44 ), ( 148, 111, 22 ),

( 185, 0, 110 ), ( 185, 37, 88 ), ( 185, 74, 66 ), ( 185, 111, 44 ), ( 185, 148, 22 ),

( 222, 0, 132 ), ( 222, 37, 110 ), ( 222, 74, 88 ), ( 222, 111, 66 ), ( 222, 148, 44 ), ( 222, 185, 22 ),

( 259, 0, 154 ), ( 259, 37, 132 ), ( 259, 74, 110 ), ( 259, 111, 88 ), ( 259, 148, 66 ), ( 259, 185, 44 ), ( 259, 222, 22 ),

( 296, 0, 176 ), ( 296, 37, 154 ), ( 296, 74, 132 ), ( 296, 111, 110 ), ( 296, 148, 88 ), ( 296, 185, 66 ), ( 296, 222, 44 ), ( 296, 259, 22 ),

( 333, 0, 198 ), ( 333, 37, 176 ), ( 333, 74, 154 ), ( 333, 111, 132 ), ( 333, 148, 110 ), ( 333, 185, 88 ), ( 333, 222, 66 ), ( 333, 259, 44 ), ( 333, 296, 22 ),

( 370, 0, 220 ), ( 370, 37, 198 ), ( 370, 74, 176 ), ( 370, 111, 154 ), ( 370, 148, 132 ), ( 370, 185, 110 ), ( 370, 222, 88 ), ( 370, 259, 66 ), ( 370, 296, 44 ), ( 370, 333, 22 ),

( 407, 0, 242 ), ( 407, 37, 220 ), ( 407, 74, 198 ), ( 407, 111, 176 ), ( 407, 148, 154 ), ( 407, 185, 132 ), ( 407, 222, 110 ), ( 407, 259, 88 ), ( 407, 296, 66 ), ( 407, 333, 44 ), ( 407, 370, 22 ),

( 444, 0, 264 ), ( 444, 37, 242 ), ( 444, 74, 220 ), ( 444, 111, 198 ), ( 444, 148, 176 ), ( 444, 185, 154 ), ( 444, 222, 132 ), ( 444, 259, 110 ), ( 444, 296, 88 ), ( 444, 333, 66 ), ( 444, 370, 44 ), ( 444, 407, 22 ),

( 481, 0, 286 ), ( 481, 37, 264 ), ( 481, 74, 242 ), ( 481, 111, 220 ), ( 481, 148, 198 ), ( 481, 185, 176 ), ( 481, 222, 154 ), ( 481, 259, 132 ), ( 481, 296, 110 ), ( 481, 333, 88 ), ( 481, 370, 66 ), ( 481, 407, 44 ), ( 481, 444, 22 ),

( 518, 0, 308 ), ( 518, 37, 286 ), ( 518, 74, 264 ), ( 518, 111, 242 ), ( 518, 148, 220 ), ( 518, 185, 198 ), ( 518, 222, 176 ), ( 518, 259, 154 ), ( 518, 296, 132 ), ( 518, 333, 110 ), ( 518, 370, 88 ), ( 518, 407, 66 ), ( 518, 444, 44 ), ( 518, 481, 22 ),

...

}

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)