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

( 39, 0, 17 ),

( 78, 0, 34 ), ( 78, 39, 17 ),

( 117, 0, 51 ), ( 117, 39, 34 ), ( 117, 78, 17 ),

( 156, 0, 68 ), ( 156, 39, 51 ), ( 156, 78, 34 ), ( 156, 117, 17 ),

( 195, 0, 85 ), ( 195, 39, 68 ), ( 195, 78, 51 ), ( 195, 117, 34 ), ( 195, 156, 17 ),

( 234, 0, 102 ), ( 234, 39, 85 ), ( 234, 78, 68 ), ( 234, 117, 51 ), ( 234, 156, 34 ), ( 234, 195, 17 ),

( 273, 0, 119 ), ( 273, 39, 102 ), ( 273, 78, 85 ), ( 273, 117, 68 ), ( 273, 156, 51 ), ( 273, 195, 34 ), ( 273, 234, 17 ),

( 312, 0, 136 ), ( 312, 39, 119 ), ( 312, 78, 102 ), ( 312, 117, 85 ), ( 312, 156, 68 ), ( 312, 195, 51 ), ( 312, 234, 34 ), ( 312, 273, 17 ),

( 351, 0, 153 ), ( 351, 39, 136 ), ( 351, 78, 119 ), ( 351, 117, 102 ), ( 351, 156, 85 ), ( 351, 195, 68 ), ( 351, 234, 51 ), ( 351, 273, 34 ), ( 351, 312, 17 ),

( 390, 0, 170 ), ( 390, 39, 153 ), ( 390, 78, 136 ), ( 390, 117, 119 ), ( 390, 156, 102 ), ( 390, 195, 85 ), ( 390, 234, 68 ), ( 390, 273, 51 ), ( 390, 312, 34 ), ( 390, 351, 17 ),

( 429, 0, 187 ), ( 429, 39, 170 ), ( 429, 78, 153 ), ( 429, 117, 136 ), ( 429, 156, 119 ), ( 429, 195, 102 ), ( 429, 234, 85 ), ( 429, 273, 68 ), ( 429, 312, 51 ), ( 429, 351, 34 ), ( 429, 390, 17 ),

( 468, 0, 204 ), ( 468, 39, 187 ), ( 468, 78, 170 ), ( 468, 117, 153 ), ( 468, 156, 136 ), ( 468, 195, 119 ), ( 468, 234, 102 ), ( 468, 273, 85 ), ( 468, 312, 68 ), ( 468, 351, 51 ), ( 468, 390, 34 ), ( 468, 429, 17 ),

( 507, 0, 221 ), ( 507, 39, 204 ), ( 507, 78, 187 ), ( 507, 117, 170 ), ( 507, 156, 153 ), ( 507, 195, 136 ), ( 507, 234, 119 ), ( 507, 273, 102 ), ( 507, 312, 85 ), ( 507, 351, 68 ), ( 507, 390, 51 ), ( 507, 429, 34 ), ( 507, 468, 17 ),

( 546, 0, 238 ), ( 546, 39, 221 ), ( 546, 78, 204 ), ( 546, 117, 187 ), ( 546, 156, 170 ), ( 546, 195, 153 ), ( 546, 234, 136 ), ( 546, 273, 119 ), ( 546, 312, 102 ), ( 546, 351, 85 ), ( 546, 390, 68 ), ( 546, 429, 51 ), ( 546, 468, 34 ), ( 546, 507, 17 ),

...

}

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)