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

( 41, 0, 16 ),

( 82, 0, 32 ), ( 82, 41, 16 ),

( 123, 0, 48 ), ( 123, 41, 32 ), ( 123, 82, 16 ),

( 164, 0, 64 ), ( 164, 41, 48 ), ( 164, 82, 32 ), ( 164, 123, 16 ),

( 205, 0, 80 ), ( 205, 41, 64 ), ( 205, 82, 48 ), ( 205, 123, 32 ), ( 205, 164, 16 ),

( 246, 0, 96 ), ( 246, 41, 80 ), ( 246, 82, 64 ), ( 246, 123, 48 ), ( 246, 164, 32 ), ( 246, 205, 16 ),

( 287, 0, 112 ), ( 287, 41, 96 ), ( 287, 82, 80 ), ( 287, 123, 64 ), ( 287, 164, 48 ), ( 287, 205, 32 ), ( 287, 246, 16 ),

( 328, 0, 128 ), ( 328, 41, 112 ), ( 328, 82, 96 ), ( 328, 123, 80 ), ( 328, 164, 64 ), ( 328, 205, 48 ), ( 328, 246, 32 ), ( 328, 287, 16 ),

( 369, 0, 144 ), ( 369, 41, 128 ), ( 369, 82, 112 ), ( 369, 123, 96 ), ( 369, 164, 80 ), ( 369, 205, 64 ), ( 369, 246, 48 ), ( 369, 287, 32 ), ( 369, 328, 16 ),

( 410, 0, 160 ), ( 410, 41, 144 ), ( 410, 82, 128 ), ( 410, 123, 112 ), ( 410, 164, 96 ), ( 410, 205, 80 ), ( 410, 246, 64 ), ( 410, 287, 48 ), ( 410, 328, 32 ), ( 410, 369, 16 ),

( 451, 0, 176 ), ( 451, 41, 160 ), ( 451, 82, 144 ), ( 451, 123, 128 ), ( 451, 164, 112 ), ( 451, 205, 96 ), ( 451, 246, 80 ), ( 451, 287, 64 ), ( 451, 328, 48 ), ( 451, 369, 32 ), ( 451, 410, 16 ),

( 492, 0, 192 ), ( 492, 41, 176 ), ( 492, 82, 160 ), ( 492, 123, 144 ), ( 492, 164, 128 ), ( 492, 205, 112 ), ( 492, 246, 96 ), ( 492, 287, 80 ), ( 492, 328, 64 ), ( 492, 369, 48 ), ( 492, 410, 32 ), ( 492, 451, 16 ),

( 533, 0, 208 ), ( 533, 41, 192 ), ( 533, 82, 176 ), ( 533, 123, 160 ), ( 533, 164, 144 ), ( 533, 205, 128 ), ( 533, 246, 112 ), ( 533, 287, 96 ), ( 533, 328, 80 ), ( 533, 369, 64 ), ( 533, 410, 48 ), ( 533, 451, 32 ), ( 533, 492, 16 ),

( 574, 0, 224 ), ( 574, 41, 208 ), ( 574, 82, 192 ), ( 574, 123, 176 ), ( 574, 164, 160 ), ( 574, 205, 144 ), ( 574, 246, 128 ), ( 574, 287, 112 ), ( 574, 328, 96 ), ( 574, 369, 80 ), ( 574, 410, 64 ), ( 574, 451, 48 ), ( 574, 492, 32 ), ( 574, 533, 16 ),

...

}

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)