The rational number 45/19 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.

45/19 = (45-0)/19 = {

( 45, 0, 19 ),

( 90, 0, 38 ), ( 90, 45, 19 ),

( 135, 0, 57 ), ( 135, 45, 38 ), ( 135, 90, 19 ),

( 180, 0, 76 ), ( 180, 45, 57 ), ( 180, 90, 38 ), ( 180, 135, 19 ),

( 225, 0, 95 ), ( 225, 45, 76 ), ( 225, 90, 57 ), ( 225, 135, 38 ), ( 225, 180, 19 ),

( 270, 0, 114 ), ( 270, 45, 95 ), ( 270, 90, 76 ), ( 270, 135, 57 ), ( 270, 180, 38 ), ( 270, 225, 19 ),

( 315, 0, 133 ), ( 315, 45, 114 ), ( 315, 90, 95 ), ( 315, 135, 76 ), ( 315, 180, 57 ), ( 315, 225, 38 ), ( 315, 270, 19 ),

( 360, 0, 152 ), ( 360, 45, 133 ), ( 360, 90, 114 ), ( 360, 135, 95 ), ( 360, 180, 76 ), ( 360, 225, 57 ), ( 360, 270, 38 ), ( 360, 315, 19 ),

( 405, 0, 171 ), ( 405, 45, 152 ), ( 405, 90, 133 ), ( 405, 135, 114 ), ( 405, 180, 95 ), ( 405, 225, 76 ), ( 405, 270, 57 ), ( 405, 315, 38 ), ( 405, 360, 19 ),

( 450, 0, 190 ), ( 450, 45, 171 ), ( 450, 90, 152 ), ( 450, 135, 133 ), ( 450, 180, 114 ), ( 450, 225, 95 ), ( 450, 270, 76 ), ( 450, 315, 57 ), ( 450, 360, 38 ), ( 450, 405, 19 ),

( 495, 0, 209 ), ( 495, 45, 190 ), ( 495, 90, 171 ), ( 495, 135, 152 ), ( 495, 180, 133 ), ( 495, 225, 114 ), ( 495, 270, 95 ), ( 495, 315, 76 ), ( 495, 360, 57 ), ( 495, 405, 38 ), ( 495, 450, 19 ),

( 540, 0, 228 ), ( 540, 45, 209 ), ( 540, 90, 190 ), ( 540, 135, 171 ), ( 540, 180, 152 ), ( 540, 225, 133 ), ( 540, 270, 114 ), ( 540, 315, 95 ), ( 540, 360, 76 ), ( 540, 405, 57 ), ( 540, 450, 38 ), ( 540, 495, 19 ),

( 585, 0, 247 ), ( 585, 45, 228 ), ( 585, 90, 209 ), ( 585, 135, 190 ), ( 585, 180, 171 ), ( 585, 225, 152 ), ( 585, 270, 133 ), ( 585, 315, 114 ), ( 585, 360, 95 ), ( 585, 405, 76 ), ( 585, 450, 57 ), ( 585, 495, 38 ), ( 585, 540, 19 ),

( 630, 0, 266 ), ( 630, 45, 247 ), ( 630, 90, 228 ), ( 630, 135, 209 ), ( 630, 180, 190 ), ( 630, 225, 171 ), ( 630, 270, 152 ), ( 630, 315, 133 ), ( 630, 360, 114 ), ( 630, 405, 95 ), ( 630, 450, 76 ), ( 630, 495, 57 ), ( 630, 540, 38 ), ( 630, 585, 19 ),

...

}

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)