The rational number 41/18 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/18 = (41-0)/18 = {

( 41, 0, 18 ),

( 82, 0, 36 ), ( 82, 41, 18 ),

( 123, 0, 54 ), ( 123, 41, 36 ), ( 123, 82, 18 ),

( 164, 0, 72 ), ( 164, 41, 54 ), ( 164, 82, 36 ), ( 164, 123, 18 ),

( 205, 0, 90 ), ( 205, 41, 72 ), ( 205, 82, 54 ), ( 205, 123, 36 ), ( 205, 164, 18 ),

( 246, 0, 108 ), ( 246, 41, 90 ), ( 246, 82, 72 ), ( 246, 123, 54 ), ( 246, 164, 36 ), ( 246, 205, 18 ),

( 287, 0, 126 ), ( 287, 41, 108 ), ( 287, 82, 90 ), ( 287, 123, 72 ), ( 287, 164, 54 ), ( 287, 205, 36 ), ( 287, 246, 18 ),

( 328, 0, 144 ), ( 328, 41, 126 ), ( 328, 82, 108 ), ( 328, 123, 90 ), ( 328, 164, 72 ), ( 328, 205, 54 ), ( 328, 246, 36 ), ( 328, 287, 18 ),

( 369, 0, 162 ), ( 369, 41, 144 ), ( 369, 82, 126 ), ( 369, 123, 108 ), ( 369, 164, 90 ), ( 369, 205, 72 ), ( 369, 246, 54 ), ( 369, 287, 36 ), ( 369, 328, 18 ),

( 410, 0, 180 ), ( 410, 41, 162 ), ( 410, 82, 144 ), ( 410, 123, 126 ), ( 410, 164, 108 ), ( 410, 205, 90 ), ( 410, 246, 72 ), ( 410, 287, 54 ), ( 410, 328, 36 ), ( 410, 369, 18 ),

( 451, 0, 198 ), ( 451, 41, 180 ), ( 451, 82, 162 ), ( 451, 123, 144 ), ( 451, 164, 126 ), ( 451, 205, 108 ), ( 451, 246, 90 ), ( 451, 287, 72 ), ( 451, 328, 54 ), ( 451, 369, 36 ), ( 451, 410, 18 ),

( 492, 0, 216 ), ( 492, 41, 198 ), ( 492, 82, 180 ), ( 492, 123, 162 ), ( 492, 164, 144 ), ( 492, 205, 126 ), ( 492, 246, 108 ), ( 492, 287, 90 ), ( 492, 328, 72 ), ( 492, 369, 54 ), ( 492, 410, 36 ), ( 492, 451, 18 ),

( 533, 0, 234 ), ( 533, 41, 216 ), ( 533, 82, 198 ), ( 533, 123, 180 ), ( 533, 164, 162 ), ( 533, 205, 144 ), ( 533, 246, 126 ), ( 533, 287, 108 ), ( 533, 328, 90 ), ( 533, 369, 72 ), ( 533, 410, 54 ), ( 533, 451, 36 ), ( 533, 492, 18 ),

( 574, 0, 252 ), ( 574, 41, 234 ), ( 574, 82, 216 ), ( 574, 123, 198 ), ( 574, 164, 180 ), ( 574, 205, 162 ), ( 574, 246, 144 ), ( 574, 287, 126 ), ( 574, 328, 108 ), ( 574, 369, 90 ), ( 574, 410, 72 ), ( 574, 451, 54 ), ( 574, 492, 36 ), ( 574, 533, 18 ),

...

}

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)