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

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

( 39, 0, 16 ),

( 78, 0, 32 ), ( 78, 39, 16 ),

( 117, 0, 48 ), ( 117, 39, 32 ), ( 117, 78, 16 ),

( 156, 0, 64 ), ( 156, 39, 48 ), ( 156, 78, 32 ), ( 156, 117, 16 ),

( 195, 0, 80 ), ( 195, 39, 64 ), ( 195, 78, 48 ), ( 195, 117, 32 ), ( 195, 156, 16 ),

( 234, 0, 96 ), ( 234, 39, 80 ), ( 234, 78, 64 ), ( 234, 117, 48 ), ( 234, 156, 32 ), ( 234, 195, 16 ),

( 273, 0, 112 ), ( 273, 39, 96 ), ( 273, 78, 80 ), ( 273, 117, 64 ), ( 273, 156, 48 ), ( 273, 195, 32 ), ( 273, 234, 16 ),

( 312, 0, 128 ), ( 312, 39, 112 ), ( 312, 78, 96 ), ( 312, 117, 80 ), ( 312, 156, 64 ), ( 312, 195, 48 ), ( 312, 234, 32 ), ( 312, 273, 16 ),

( 351, 0, 144 ), ( 351, 39, 128 ), ( 351, 78, 112 ), ( 351, 117, 96 ), ( 351, 156, 80 ), ( 351, 195, 64 ), ( 351, 234, 48 ), ( 351, 273, 32 ), ( 351, 312, 16 ),

( 390, 0, 160 ), ( 390, 39, 144 ), ( 390, 78, 128 ), ( 390, 117, 112 ), ( 390, 156, 96 ), ( 390, 195, 80 ), ( 390, 234, 64 ), ( 390, 273, 48 ), ( 390, 312, 32 ), ( 390, 351, 16 ),

( 429, 0, 176 ), ( 429, 39, 160 ), ( 429, 78, 144 ), ( 429, 117, 128 ), ( 429, 156, 112 ), ( 429, 195, 96 ), ( 429, 234, 80 ), ( 429, 273, 64 ), ( 429, 312, 48 ), ( 429, 351, 32 ), ( 429, 390, 16 ),

( 468, 0, 192 ), ( 468, 39, 176 ), ( 468, 78, 160 ), ( 468, 117, 144 ), ( 468, 156, 128 ), ( 468, 195, 112 ), ( 468, 234, 96 ), ( 468, 273, 80 ), ( 468, 312, 64 ), ( 468, 351, 48 ), ( 468, 390, 32 ), ( 468, 429, 16 ),

( 507, 0, 208 ), ( 507, 39, 192 ), ( 507, 78, 176 ), ( 507, 117, 160 ), ( 507, 156, 144 ), ( 507, 195, 128 ), ( 507, 234, 112 ), ( 507, 273, 96 ), ( 507, 312, 80 ), ( 507, 351, 64 ), ( 507, 390, 48 ), ( 507, 429, 32 ), ( 507, 468, 16 ),

( 546, 0, 224 ), ( 546, 39, 208 ), ( 546, 78, 192 ), ( 546, 117, 176 ), ( 546, 156, 160 ), ( 546, 195, 144 ), ( 546, 234, 128 ), ( 546, 273, 112 ), ( 546, 312, 96 ), ( 546, 351, 80 ), ( 546, 390, 64 ), ( 546, 429, 48 ), ( 546, 468, 32 ), ( 546, 507, 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)