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

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

( 42, 0, 17 ),

( 84, 0, 34 ), ( 84, 42, 17 ),

( 126, 0, 51 ), ( 126, 42, 34 ), ( 126, 84, 17 ),

( 168, 0, 68 ), ( 168, 42, 51 ), ( 168, 84, 34 ), ( 168, 126, 17 ),

( 210, 0, 85 ), ( 210, 42, 68 ), ( 210, 84, 51 ), ( 210, 126, 34 ), ( 210, 168, 17 ),

( 252, 0, 102 ), ( 252, 42, 85 ), ( 252, 84, 68 ), ( 252, 126, 51 ), ( 252, 168, 34 ), ( 252, 210, 17 ),

( 294, 0, 119 ), ( 294, 42, 102 ), ( 294, 84, 85 ), ( 294, 126, 68 ), ( 294, 168, 51 ), ( 294, 210, 34 ), ( 294, 252, 17 ),

( 336, 0, 136 ), ( 336, 42, 119 ), ( 336, 84, 102 ), ( 336, 126, 85 ), ( 336, 168, 68 ), ( 336, 210, 51 ), ( 336, 252, 34 ), ( 336, 294, 17 ),

( 378, 0, 153 ), ( 378, 42, 136 ), ( 378, 84, 119 ), ( 378, 126, 102 ), ( 378, 168, 85 ), ( 378, 210, 68 ), ( 378, 252, 51 ), ( 378, 294, 34 ), ( 378, 336, 17 ),

( 420, 0, 170 ), ( 420, 42, 153 ), ( 420, 84, 136 ), ( 420, 126, 119 ), ( 420, 168, 102 ), ( 420, 210, 85 ), ( 420, 252, 68 ), ( 420, 294, 51 ), ( 420, 336, 34 ), ( 420, 378, 17 ),

( 462, 0, 187 ), ( 462, 42, 170 ), ( 462, 84, 153 ), ( 462, 126, 136 ), ( 462, 168, 119 ), ( 462, 210, 102 ), ( 462, 252, 85 ), ( 462, 294, 68 ), ( 462, 336, 51 ), ( 462, 378, 34 ), ( 462, 420, 17 ),

( 504, 0, 204 ), ( 504, 42, 187 ), ( 504, 84, 170 ), ( 504, 126, 153 ), ( 504, 168, 136 ), ( 504, 210, 119 ), ( 504, 252, 102 ), ( 504, 294, 85 ), ( 504, 336, 68 ), ( 504, 378, 51 ), ( 504, 420, 34 ), ( 504, 462, 17 ),

( 546, 0, 221 ), ( 546, 42, 204 ), ( 546, 84, 187 ), ( 546, 126, 170 ), ( 546, 168, 153 ), ( 546, 210, 136 ), ( 546, 252, 119 ), ( 546, 294, 102 ), ( 546, 336, 85 ), ( 546, 378, 68 ), ( 546, 420, 51 ), ( 546, 462, 34 ), ( 546, 504, 17 ),

( 588, 0, 238 ), ( 588, 42, 221 ), ( 588, 84, 204 ), ( 588, 126, 187 ), ( 588, 168, 170 ), ( 588, 210, 153 ), ( 588, 252, 136 ), ( 588, 294, 119 ), ( 588, 336, 102 ), ( 588, 378, 85 ), ( 588, 420, 68 ), ( 588, 462, 51 ), ( 588, 504, 34 ), ( 588, 546, 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)