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

( 41, 0, 9 ),

( 82, 0, 18 ), ( 82, 41, 9 ),

( 123, 0, 27 ), ( 123, 41, 18 ), ( 123, 82, 9 ),

( 164, 0, 36 ), ( 164, 41, 27 ), ( 164, 82, 18 ), ( 164, 123, 9 ),

( 205, 0, 45 ), ( 205, 41, 36 ), ( 205, 82, 27 ), ( 205, 123, 18 ), ( 205, 164, 9 ),

( 246, 0, 54 ), ( 246, 41, 45 ), ( 246, 82, 36 ), ( 246, 123, 27 ), ( 246, 164, 18 ), ( 246, 205, 9 ),

( 287, 0, 63 ), ( 287, 41, 54 ), ( 287, 82, 45 ), ( 287, 123, 36 ), ( 287, 164, 27 ), ( 287, 205, 18 ), ( 287, 246, 9 ),

( 328, 0, 72 ), ( 328, 41, 63 ), ( 328, 82, 54 ), ( 328, 123, 45 ), ( 328, 164, 36 ), ( 328, 205, 27 ), ( 328, 246, 18 ), ( 328, 287, 9 ),

( 369, 0, 81 ), ( 369, 41, 72 ), ( 369, 82, 63 ), ( 369, 123, 54 ), ( 369, 164, 45 ), ( 369, 205, 36 ), ( 369, 246, 27 ), ( 369, 287, 18 ), ( 369, 328, 9 ),

( 410, 0, 90 ), ( 410, 41, 81 ), ( 410, 82, 72 ), ( 410, 123, 63 ), ( 410, 164, 54 ), ( 410, 205, 45 ), ( 410, 246, 36 ), ( 410, 287, 27 ), ( 410, 328, 18 ), ( 410, 369, 9 ),

( 451, 0, 99 ), ( 451, 41, 90 ), ( 451, 82, 81 ), ( 451, 123, 72 ), ( 451, 164, 63 ), ( 451, 205, 54 ), ( 451, 246, 45 ), ( 451, 287, 36 ), ( 451, 328, 27 ), ( 451, 369, 18 ), ( 451, 410, 9 ),

( 492, 0, 108 ), ( 492, 41, 99 ), ( 492, 82, 90 ), ( 492, 123, 81 ), ( 492, 164, 72 ), ( 492, 205, 63 ), ( 492, 246, 54 ), ( 492, 287, 45 ), ( 492, 328, 36 ), ( 492, 369, 27 ), ( 492, 410, 18 ), ( 492, 451, 9 ),

( 533, 0, 117 ), ( 533, 41, 108 ), ( 533, 82, 99 ), ( 533, 123, 90 ), ( 533, 164, 81 ), ( 533, 205, 72 ), ( 533, 246, 63 ), ( 533, 287, 54 ), ( 533, 328, 45 ), ( 533, 369, 36 ), ( 533, 410, 27 ), ( 533, 451, 18 ), ( 533, 492, 9 ),

( 574, 0, 126 ), ( 574, 41, 117 ), ( 574, 82, 108 ), ( 574, 123, 99 ), ( 574, 164, 90 ), ( 574, 205, 81 ), ( 574, 246, 72 ), ( 574, 287, 63 ), ( 574, 328, 54 ), ( 574, 369, 45 ), ( 574, 410, 36 ), ( 574, 451, 27 ), ( 574, 492, 18 ), ( 574, 533, 9 ),

...

}

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)