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

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

( 46, 0, 21 ),

( 92, 0, 42 ), ( 92, 46, 21 ),

( 138, 0, 63 ), ( 138, 46, 42 ), ( 138, 92, 21 ),

( 184, 0, 84 ), ( 184, 46, 63 ), ( 184, 92, 42 ), ( 184, 138, 21 ),

( 230, 0, 105 ), ( 230, 46, 84 ), ( 230, 92, 63 ), ( 230, 138, 42 ), ( 230, 184, 21 ),

( 276, 0, 126 ), ( 276, 46, 105 ), ( 276, 92, 84 ), ( 276, 138, 63 ), ( 276, 184, 42 ), ( 276, 230, 21 ),

( 322, 0, 147 ), ( 322, 46, 126 ), ( 322, 92, 105 ), ( 322, 138, 84 ), ( 322, 184, 63 ), ( 322, 230, 42 ), ( 322, 276, 21 ),

( 368, 0, 168 ), ( 368, 46, 147 ), ( 368, 92, 126 ), ( 368, 138, 105 ), ( 368, 184, 84 ), ( 368, 230, 63 ), ( 368, 276, 42 ), ( 368, 322, 21 ),

( 414, 0, 189 ), ( 414, 46, 168 ), ( 414, 92, 147 ), ( 414, 138, 126 ), ( 414, 184, 105 ), ( 414, 230, 84 ), ( 414, 276, 63 ), ( 414, 322, 42 ), ( 414, 368, 21 ),

( 460, 0, 210 ), ( 460, 46, 189 ), ( 460, 92, 168 ), ( 460, 138, 147 ), ( 460, 184, 126 ), ( 460, 230, 105 ), ( 460, 276, 84 ), ( 460, 322, 63 ), ( 460, 368, 42 ), ( 460, 414, 21 ),

( 506, 0, 231 ), ( 506, 46, 210 ), ( 506, 92, 189 ), ( 506, 138, 168 ), ( 506, 184, 147 ), ( 506, 230, 126 ), ( 506, 276, 105 ), ( 506, 322, 84 ), ( 506, 368, 63 ), ( 506, 414, 42 ), ( 506, 460, 21 ),

( 552, 0, 252 ), ( 552, 46, 231 ), ( 552, 92, 210 ), ( 552, 138, 189 ), ( 552, 184, 168 ), ( 552, 230, 147 ), ( 552, 276, 126 ), ( 552, 322, 105 ), ( 552, 368, 84 ), ( 552, 414, 63 ), ( 552, 460, 42 ), ( 552, 506, 21 ),

( 598, 0, 273 ), ( 598, 46, 252 ), ( 598, 92, 231 ), ( 598, 138, 210 ), ( 598, 184, 189 ), ( 598, 230, 168 ), ( 598, 276, 147 ), ( 598, 322, 126 ), ( 598, 368, 105 ), ( 598, 414, 84 ), ( 598, 460, 63 ), ( 598, 506, 42 ), ( 598, 552, 21 ),

( 644, 0, 294 ), ( 644, 46, 273 ), ( 644, 92, 252 ), ( 644, 138, 231 ), ( 644, 184, 210 ), ( 644, 230, 189 ), ( 644, 276, 168 ), ( 644, 322, 147 ), ( 644, 368, 126 ), ( 644, 414, 105 ), ( 644, 460, 84 ), ( 644, 506, 63 ), ( 644, 552, 42 ), ( 644, 598, 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)