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

( 41, 0, 12 ),

( 82, 0, 24 ), ( 82, 41, 12 ),

( 123, 0, 36 ), ( 123, 41, 24 ), ( 123, 82, 12 ),

( 164, 0, 48 ), ( 164, 41, 36 ), ( 164, 82, 24 ), ( 164, 123, 12 ),

( 205, 0, 60 ), ( 205, 41, 48 ), ( 205, 82, 36 ), ( 205, 123, 24 ), ( 205, 164, 12 ),

( 246, 0, 72 ), ( 246, 41, 60 ), ( 246, 82, 48 ), ( 246, 123, 36 ), ( 246, 164, 24 ), ( 246, 205, 12 ),

( 287, 0, 84 ), ( 287, 41, 72 ), ( 287, 82, 60 ), ( 287, 123, 48 ), ( 287, 164, 36 ), ( 287, 205, 24 ), ( 287, 246, 12 ),

( 328, 0, 96 ), ( 328, 41, 84 ), ( 328, 82, 72 ), ( 328, 123, 60 ), ( 328, 164, 48 ), ( 328, 205, 36 ), ( 328, 246, 24 ), ( 328, 287, 12 ),

( 369, 0, 108 ), ( 369, 41, 96 ), ( 369, 82, 84 ), ( 369, 123, 72 ), ( 369, 164, 60 ), ( 369, 205, 48 ), ( 369, 246, 36 ), ( 369, 287, 24 ), ( 369, 328, 12 ),

( 410, 0, 120 ), ( 410, 41, 108 ), ( 410, 82, 96 ), ( 410, 123, 84 ), ( 410, 164, 72 ), ( 410, 205, 60 ), ( 410, 246, 48 ), ( 410, 287, 36 ), ( 410, 328, 24 ), ( 410, 369, 12 ),

( 451, 0, 132 ), ( 451, 41, 120 ), ( 451, 82, 108 ), ( 451, 123, 96 ), ( 451, 164, 84 ), ( 451, 205, 72 ), ( 451, 246, 60 ), ( 451, 287, 48 ), ( 451, 328, 36 ), ( 451, 369, 24 ), ( 451, 410, 12 ),

( 492, 0, 144 ), ( 492, 41, 132 ), ( 492, 82, 120 ), ( 492, 123, 108 ), ( 492, 164, 96 ), ( 492, 205, 84 ), ( 492, 246, 72 ), ( 492, 287, 60 ), ( 492, 328, 48 ), ( 492, 369, 36 ), ( 492, 410, 24 ), ( 492, 451, 12 ),

( 533, 0, 156 ), ( 533, 41, 144 ), ( 533, 82, 132 ), ( 533, 123, 120 ), ( 533, 164, 108 ), ( 533, 205, 96 ), ( 533, 246, 84 ), ( 533, 287, 72 ), ( 533, 328, 60 ), ( 533, 369, 48 ), ( 533, 410, 36 ), ( 533, 451, 24 ), ( 533, 492, 12 ),

( 574, 0, 168 ), ( 574, 41, 156 ), ( 574, 82, 144 ), ( 574, 123, 132 ), ( 574, 164, 120 ), ( 574, 205, 108 ), ( 574, 246, 96 ), ( 574, 287, 84 ), ( 574, 328, 72 ), ( 574, 369, 60 ), ( 574, 410, 48 ), ( 574, 451, 36 ), ( 574, 492, 24 ), ( 574, 533, 12 ),

...

}

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)