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

( 41, 0, 23 ),

( 82, 0, 46 ), ( 82, 41, 23 ),

( 123, 0, 69 ), ( 123, 41, 46 ), ( 123, 82, 23 ),

( 164, 0, 92 ), ( 164, 41, 69 ), ( 164, 82, 46 ), ( 164, 123, 23 ),

( 205, 0, 115 ), ( 205, 41, 92 ), ( 205, 82, 69 ), ( 205, 123, 46 ), ( 205, 164, 23 ),

( 246, 0, 138 ), ( 246, 41, 115 ), ( 246, 82, 92 ), ( 246, 123, 69 ), ( 246, 164, 46 ), ( 246, 205, 23 ),

( 287, 0, 161 ), ( 287, 41, 138 ), ( 287, 82, 115 ), ( 287, 123, 92 ), ( 287, 164, 69 ), ( 287, 205, 46 ), ( 287, 246, 23 ),

( 328, 0, 184 ), ( 328, 41, 161 ), ( 328, 82, 138 ), ( 328, 123, 115 ), ( 328, 164, 92 ), ( 328, 205, 69 ), ( 328, 246, 46 ), ( 328, 287, 23 ),

( 369, 0, 207 ), ( 369, 41, 184 ), ( 369, 82, 161 ), ( 369, 123, 138 ), ( 369, 164, 115 ), ( 369, 205, 92 ), ( 369, 246, 69 ), ( 369, 287, 46 ), ( 369, 328, 23 ),

( 410, 0, 230 ), ( 410, 41, 207 ), ( 410, 82, 184 ), ( 410, 123, 161 ), ( 410, 164, 138 ), ( 410, 205, 115 ), ( 410, 246, 92 ), ( 410, 287, 69 ), ( 410, 328, 46 ), ( 410, 369, 23 ),

( 451, 0, 253 ), ( 451, 41, 230 ), ( 451, 82, 207 ), ( 451, 123, 184 ), ( 451, 164, 161 ), ( 451, 205, 138 ), ( 451, 246, 115 ), ( 451, 287, 92 ), ( 451, 328, 69 ), ( 451, 369, 46 ), ( 451, 410, 23 ),

( 492, 0, 276 ), ( 492, 41, 253 ), ( 492, 82, 230 ), ( 492, 123, 207 ), ( 492, 164, 184 ), ( 492, 205, 161 ), ( 492, 246, 138 ), ( 492, 287, 115 ), ( 492, 328, 92 ), ( 492, 369, 69 ), ( 492, 410, 46 ), ( 492, 451, 23 ),

( 533, 0, 299 ), ( 533, 41, 276 ), ( 533, 82, 253 ), ( 533, 123, 230 ), ( 533, 164, 207 ), ( 533, 205, 184 ), ( 533, 246, 161 ), ( 533, 287, 138 ), ( 533, 328, 115 ), ( 533, 369, 92 ), ( 533, 410, 69 ), ( 533, 451, 46 ), ( 533, 492, 23 ),

( 574, 0, 322 ), ( 574, 41, 299 ), ( 574, 82, 276 ), ( 574, 123, 253 ), ( 574, 164, 230 ), ( 574, 205, 207 ), ( 574, 246, 184 ), ( 574, 287, 161 ), ( 574, 328, 138 ), ( 574, 369, 115 ), ( 574, 410, 92 ), ( 574, 451, 69 ), ( 574, 492, 46 ), ( 574, 533, 23 ),

...

}

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)