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

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

( 29, 0, 16 ),

( 58, 0, 32 ), ( 58, 29, 16 ),

( 87, 0, 48 ), ( 87, 29, 32 ), ( 87, 58, 16 ),

( 116, 0, 64 ), ( 116, 29, 48 ), ( 116, 58, 32 ), ( 116, 87, 16 ),

( 145, 0, 80 ), ( 145, 29, 64 ), ( 145, 58, 48 ), ( 145, 87, 32 ), ( 145, 116, 16 ),

( 174, 0, 96 ), ( 174, 29, 80 ), ( 174, 58, 64 ), ( 174, 87, 48 ), ( 174, 116, 32 ), ( 174, 145, 16 ),

( 203, 0, 112 ), ( 203, 29, 96 ), ( 203, 58, 80 ), ( 203, 87, 64 ), ( 203, 116, 48 ), ( 203, 145, 32 ), ( 203, 174, 16 ),

( 232, 0, 128 ), ( 232, 29, 112 ), ( 232, 58, 96 ), ( 232, 87, 80 ), ( 232, 116, 64 ), ( 232, 145, 48 ), ( 232, 174, 32 ), ( 232, 203, 16 ),

( 261, 0, 144 ), ( 261, 29, 128 ), ( 261, 58, 112 ), ( 261, 87, 96 ), ( 261, 116, 80 ), ( 261, 145, 64 ), ( 261, 174, 48 ), ( 261, 203, 32 ), ( 261, 232, 16 ),

( 290, 0, 160 ), ( 290, 29, 144 ), ( 290, 58, 128 ), ( 290, 87, 112 ), ( 290, 116, 96 ), ( 290, 145, 80 ), ( 290, 174, 64 ), ( 290, 203, 48 ), ( 290, 232, 32 ), ( 290, 261, 16 ),

( 319, 0, 176 ), ( 319, 29, 160 ), ( 319, 58, 144 ), ( 319, 87, 128 ), ( 319, 116, 112 ), ( 319, 145, 96 ), ( 319, 174, 80 ), ( 319, 203, 64 ), ( 319, 232, 48 ), ( 319, 261, 32 ), ( 319, 290, 16 ),

( 348, 0, 192 ), ( 348, 29, 176 ), ( 348, 58, 160 ), ( 348, 87, 144 ), ( 348, 116, 128 ), ( 348, 145, 112 ), ( 348, 174, 96 ), ( 348, 203, 80 ), ( 348, 232, 64 ), ( 348, 261, 48 ), ( 348, 290, 32 ), ( 348, 319, 16 ),

( 377, 0, 208 ), ( 377, 29, 192 ), ( 377, 58, 176 ), ( 377, 87, 160 ), ( 377, 116, 144 ), ( 377, 145, 128 ), ( 377, 174, 112 ), ( 377, 203, 96 ), ( 377, 232, 80 ), ( 377, 261, 64 ), ( 377, 290, 48 ), ( 377, 319, 32 ), ( 377, 348, 16 ),

( 406, 0, 224 ), ( 406, 29, 208 ), ( 406, 58, 192 ), ( 406, 87, 176 ), ( 406, 116, 160 ), ( 406, 145, 144 ), ( 406, 174, 128 ), ( 406, 203, 112 ), ( 406, 232, 96 ), ( 406, 261, 80 ), ( 406, 290, 64 ), ( 406, 319, 48 ), ( 406, 348, 32 ), ( 406, 377, 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)