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

( 39, 0, 19 ),

( 78, 0, 38 ), ( 78, 39, 19 ),

( 117, 0, 57 ), ( 117, 39, 38 ), ( 117, 78, 19 ),

( 156, 0, 76 ), ( 156, 39, 57 ), ( 156, 78, 38 ), ( 156, 117, 19 ),

( 195, 0, 95 ), ( 195, 39, 76 ), ( 195, 78, 57 ), ( 195, 117, 38 ), ( 195, 156, 19 ),

( 234, 0, 114 ), ( 234, 39, 95 ), ( 234, 78, 76 ), ( 234, 117, 57 ), ( 234, 156, 38 ), ( 234, 195, 19 ),

( 273, 0, 133 ), ( 273, 39, 114 ), ( 273, 78, 95 ), ( 273, 117, 76 ), ( 273, 156, 57 ), ( 273, 195, 38 ), ( 273, 234, 19 ),

( 312, 0, 152 ), ( 312, 39, 133 ), ( 312, 78, 114 ), ( 312, 117, 95 ), ( 312, 156, 76 ), ( 312, 195, 57 ), ( 312, 234, 38 ), ( 312, 273, 19 ),

( 351, 0, 171 ), ( 351, 39, 152 ), ( 351, 78, 133 ), ( 351, 117, 114 ), ( 351, 156, 95 ), ( 351, 195, 76 ), ( 351, 234, 57 ), ( 351, 273, 38 ), ( 351, 312, 19 ),

( 390, 0, 190 ), ( 390, 39, 171 ), ( 390, 78, 152 ), ( 390, 117, 133 ), ( 390, 156, 114 ), ( 390, 195, 95 ), ( 390, 234, 76 ), ( 390, 273, 57 ), ( 390, 312, 38 ), ( 390, 351, 19 ),

( 429, 0, 209 ), ( 429, 39, 190 ), ( 429, 78, 171 ), ( 429, 117, 152 ), ( 429, 156, 133 ), ( 429, 195, 114 ), ( 429, 234, 95 ), ( 429, 273, 76 ), ( 429, 312, 57 ), ( 429, 351, 38 ), ( 429, 390, 19 ),

( 468, 0, 228 ), ( 468, 39, 209 ), ( 468, 78, 190 ), ( 468, 117, 171 ), ( 468, 156, 152 ), ( 468, 195, 133 ), ( 468, 234, 114 ), ( 468, 273, 95 ), ( 468, 312, 76 ), ( 468, 351, 57 ), ( 468, 390, 38 ), ( 468, 429, 19 ),

( 507, 0, 247 ), ( 507, 39, 228 ), ( 507, 78, 209 ), ( 507, 117, 190 ), ( 507, 156, 171 ), ( 507, 195, 152 ), ( 507, 234, 133 ), ( 507, 273, 114 ), ( 507, 312, 95 ), ( 507, 351, 76 ), ( 507, 390, 57 ), ( 507, 429, 38 ), ( 507, 468, 19 ),

( 546, 0, 266 ), ( 546, 39, 247 ), ( 546, 78, 228 ), ( 546, 117, 209 ), ( 546, 156, 190 ), ( 546, 195, 171 ), ( 546, 234, 152 ), ( 546, 273, 133 ), ( 546, 312, 114 ), ( 546, 351, 95 ), ( 546, 390, 76 ), ( 546, 429, 57 ), ( 546, 468, 38 ), ( 546, 507, 19 ),

...

}

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)