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

38/17 = (38-0)/17 = {

( 38, 0, 17 ),

( 76, 0, 34 ), ( 76, 38, 17 ),

( 114, 0, 51 ), ( 114, 38, 34 ), ( 114, 76, 17 ),

( 152, 0, 68 ), ( 152, 38, 51 ), ( 152, 76, 34 ), ( 152, 114, 17 ),

( 190, 0, 85 ), ( 190, 38, 68 ), ( 190, 76, 51 ), ( 190, 114, 34 ), ( 190, 152, 17 ),

( 228, 0, 102 ), ( 228, 38, 85 ), ( 228, 76, 68 ), ( 228, 114, 51 ), ( 228, 152, 34 ), ( 228, 190, 17 ),

( 266, 0, 119 ), ( 266, 38, 102 ), ( 266, 76, 85 ), ( 266, 114, 68 ), ( 266, 152, 51 ), ( 266, 190, 34 ), ( 266, 228, 17 ),

( 304, 0, 136 ), ( 304, 38, 119 ), ( 304, 76, 102 ), ( 304, 114, 85 ), ( 304, 152, 68 ), ( 304, 190, 51 ), ( 304, 228, 34 ), ( 304, 266, 17 ),

( 342, 0, 153 ), ( 342, 38, 136 ), ( 342, 76, 119 ), ( 342, 114, 102 ), ( 342, 152, 85 ), ( 342, 190, 68 ), ( 342, 228, 51 ), ( 342, 266, 34 ), ( 342, 304, 17 ),

( 380, 0, 170 ), ( 380, 38, 153 ), ( 380, 76, 136 ), ( 380, 114, 119 ), ( 380, 152, 102 ), ( 380, 190, 85 ), ( 380, 228, 68 ), ( 380, 266, 51 ), ( 380, 304, 34 ), ( 380, 342, 17 ),

( 418, 0, 187 ), ( 418, 38, 170 ), ( 418, 76, 153 ), ( 418, 114, 136 ), ( 418, 152, 119 ), ( 418, 190, 102 ), ( 418, 228, 85 ), ( 418, 266, 68 ), ( 418, 304, 51 ), ( 418, 342, 34 ), ( 418, 380, 17 ),

( 456, 0, 204 ), ( 456, 38, 187 ), ( 456, 76, 170 ), ( 456, 114, 153 ), ( 456, 152, 136 ), ( 456, 190, 119 ), ( 456, 228, 102 ), ( 456, 266, 85 ), ( 456, 304, 68 ), ( 456, 342, 51 ), ( 456, 380, 34 ), ( 456, 418, 17 ),

( 494, 0, 221 ), ( 494, 38, 204 ), ( 494, 76, 187 ), ( 494, 114, 170 ), ( 494, 152, 153 ), ( 494, 190, 136 ), ( 494, 228, 119 ), ( 494, 266, 102 ), ( 494, 304, 85 ), ( 494, 342, 68 ), ( 494, 380, 51 ), ( 494, 418, 34 ), ( 494, 456, 17 ),

( 532, 0, 238 ), ( 532, 38, 221 ), ( 532, 76, 204 ), ( 532, 114, 187 ), ( 532, 152, 170 ), ( 532, 190, 153 ), ( 532, 228, 136 ), ( 532, 266, 119 ), ( 532, 304, 102 ), ( 532, 342, 85 ), ( 532, 380, 68 ), ( 532, 418, 51 ), ( 532, 456, 34 ), ( 532, 494, 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)