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

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

( 41, 0, 21 ),

( 82, 0, 42 ), ( 82, 41, 21 ),

( 123, 0, 63 ), ( 123, 41, 42 ), ( 123, 82, 21 ),

( 164, 0, 84 ), ( 164, 41, 63 ), ( 164, 82, 42 ), ( 164, 123, 21 ),

( 205, 0, 105 ), ( 205, 41, 84 ), ( 205, 82, 63 ), ( 205, 123, 42 ), ( 205, 164, 21 ),

( 246, 0, 126 ), ( 246, 41, 105 ), ( 246, 82, 84 ), ( 246, 123, 63 ), ( 246, 164, 42 ), ( 246, 205, 21 ),

( 287, 0, 147 ), ( 287, 41, 126 ), ( 287, 82, 105 ), ( 287, 123, 84 ), ( 287, 164, 63 ), ( 287, 205, 42 ), ( 287, 246, 21 ),

( 328, 0, 168 ), ( 328, 41, 147 ), ( 328, 82, 126 ), ( 328, 123, 105 ), ( 328, 164, 84 ), ( 328, 205, 63 ), ( 328, 246, 42 ), ( 328, 287, 21 ),

( 369, 0, 189 ), ( 369, 41, 168 ), ( 369, 82, 147 ), ( 369, 123, 126 ), ( 369, 164, 105 ), ( 369, 205, 84 ), ( 369, 246, 63 ), ( 369, 287, 42 ), ( 369, 328, 21 ),

( 410, 0, 210 ), ( 410, 41, 189 ), ( 410, 82, 168 ), ( 410, 123, 147 ), ( 410, 164, 126 ), ( 410, 205, 105 ), ( 410, 246, 84 ), ( 410, 287, 63 ), ( 410, 328, 42 ), ( 410, 369, 21 ),

( 451, 0, 231 ), ( 451, 41, 210 ), ( 451, 82, 189 ), ( 451, 123, 168 ), ( 451, 164, 147 ), ( 451, 205, 126 ), ( 451, 246, 105 ), ( 451, 287, 84 ), ( 451, 328, 63 ), ( 451, 369, 42 ), ( 451, 410, 21 ),

( 492, 0, 252 ), ( 492, 41, 231 ), ( 492, 82, 210 ), ( 492, 123, 189 ), ( 492, 164, 168 ), ( 492, 205, 147 ), ( 492, 246, 126 ), ( 492, 287, 105 ), ( 492, 328, 84 ), ( 492, 369, 63 ), ( 492, 410, 42 ), ( 492, 451, 21 ),

( 533, 0, 273 ), ( 533, 41, 252 ), ( 533, 82, 231 ), ( 533, 123, 210 ), ( 533, 164, 189 ), ( 533, 205, 168 ), ( 533, 246, 147 ), ( 533, 287, 126 ), ( 533, 328, 105 ), ( 533, 369, 84 ), ( 533, 410, 63 ), ( 533, 451, 42 ), ( 533, 492, 21 ),

( 574, 0, 294 ), ( 574, 41, 273 ), ( 574, 82, 252 ), ( 574, 123, 231 ), ( 574, 164, 210 ), ( 574, 205, 189 ), ( 574, 246, 168 ), ( 574, 287, 147 ), ( 574, 328, 126 ), ( 574, 369, 105 ), ( 574, 410, 84 ), ( 574, 451, 63 ), ( 574, 492, 42 ), ( 574, 533, 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)