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

43/21 = (43-0)/21 = {

( 43, 0, 21 ),

( 86, 0, 42 ), ( 86, 43, 21 ),

( 129, 0, 63 ), ( 129, 43, 42 ), ( 129, 86, 21 ),

( 172, 0, 84 ), ( 172, 43, 63 ), ( 172, 86, 42 ), ( 172, 129, 21 ),

( 215, 0, 105 ), ( 215, 43, 84 ), ( 215, 86, 63 ), ( 215, 129, 42 ), ( 215, 172, 21 ),

( 258, 0, 126 ), ( 258, 43, 105 ), ( 258, 86, 84 ), ( 258, 129, 63 ), ( 258, 172, 42 ), ( 258, 215, 21 ),

( 301, 0, 147 ), ( 301, 43, 126 ), ( 301, 86, 105 ), ( 301, 129, 84 ), ( 301, 172, 63 ), ( 301, 215, 42 ), ( 301, 258, 21 ),

( 344, 0, 168 ), ( 344, 43, 147 ), ( 344, 86, 126 ), ( 344, 129, 105 ), ( 344, 172, 84 ), ( 344, 215, 63 ), ( 344, 258, 42 ), ( 344, 301, 21 ),

( 387, 0, 189 ), ( 387, 43, 168 ), ( 387, 86, 147 ), ( 387, 129, 126 ), ( 387, 172, 105 ), ( 387, 215, 84 ), ( 387, 258, 63 ), ( 387, 301, 42 ), ( 387, 344, 21 ),

( 430, 0, 210 ), ( 430, 43, 189 ), ( 430, 86, 168 ), ( 430, 129, 147 ), ( 430, 172, 126 ), ( 430, 215, 105 ), ( 430, 258, 84 ), ( 430, 301, 63 ), ( 430, 344, 42 ), ( 430, 387, 21 ),

( 473, 0, 231 ), ( 473, 43, 210 ), ( 473, 86, 189 ), ( 473, 129, 168 ), ( 473, 172, 147 ), ( 473, 215, 126 ), ( 473, 258, 105 ), ( 473, 301, 84 ), ( 473, 344, 63 ), ( 473, 387, 42 ), ( 473, 430, 21 ),

( 516, 0, 252 ), ( 516, 43, 231 ), ( 516, 86, 210 ), ( 516, 129, 189 ), ( 516, 172, 168 ), ( 516, 215, 147 ), ( 516, 258, 126 ), ( 516, 301, 105 ), ( 516, 344, 84 ), ( 516, 387, 63 ), ( 516, 430, 42 ), ( 516, 473, 21 ),

( 559, 0, 273 ), ( 559, 43, 252 ), ( 559, 86, 231 ), ( 559, 129, 210 ), ( 559, 172, 189 ), ( 559, 215, 168 ), ( 559, 258, 147 ), ( 559, 301, 126 ), ( 559, 344, 105 ), ( 559, 387, 84 ), ( 559, 430, 63 ), ( 559, 473, 42 ), ( 559, 516, 21 ),

( 602, 0, 294 ), ( 602, 43, 273 ), ( 602, 86, 252 ), ( 602, 129, 231 ), ( 602, 172, 210 ), ( 602, 215, 189 ), ( 602, 258, 168 ), ( 602, 301, 147 ), ( 602, 344, 126 ), ( 602, 387, 105 ), ( 602, 430, 84 ), ( 602, 473, 63 ), ( 602, 516, 42 ), ( 602, 559, 21 ),

...

}

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)