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

( 45, 0, 17 ),

( 90, 0, 34 ), ( 90, 45, 17 ),

( 135, 0, 51 ), ( 135, 45, 34 ), ( 135, 90, 17 ),

( 180, 0, 68 ), ( 180, 45, 51 ), ( 180, 90, 34 ), ( 180, 135, 17 ),

( 225, 0, 85 ), ( 225, 45, 68 ), ( 225, 90, 51 ), ( 225, 135, 34 ), ( 225, 180, 17 ),

( 270, 0, 102 ), ( 270, 45, 85 ), ( 270, 90, 68 ), ( 270, 135, 51 ), ( 270, 180, 34 ), ( 270, 225, 17 ),

( 315, 0, 119 ), ( 315, 45, 102 ), ( 315, 90, 85 ), ( 315, 135, 68 ), ( 315, 180, 51 ), ( 315, 225, 34 ), ( 315, 270, 17 ),

( 360, 0, 136 ), ( 360, 45, 119 ), ( 360, 90, 102 ), ( 360, 135, 85 ), ( 360, 180, 68 ), ( 360, 225, 51 ), ( 360, 270, 34 ), ( 360, 315, 17 ),

( 405, 0, 153 ), ( 405, 45, 136 ), ( 405, 90, 119 ), ( 405, 135, 102 ), ( 405, 180, 85 ), ( 405, 225, 68 ), ( 405, 270, 51 ), ( 405, 315, 34 ), ( 405, 360, 17 ),

( 450, 0, 170 ), ( 450, 45, 153 ), ( 450, 90, 136 ), ( 450, 135, 119 ), ( 450, 180, 102 ), ( 450, 225, 85 ), ( 450, 270, 68 ), ( 450, 315, 51 ), ( 450, 360, 34 ), ( 450, 405, 17 ),

( 495, 0, 187 ), ( 495, 45, 170 ), ( 495, 90, 153 ), ( 495, 135, 136 ), ( 495, 180, 119 ), ( 495, 225, 102 ), ( 495, 270, 85 ), ( 495, 315, 68 ), ( 495, 360, 51 ), ( 495, 405, 34 ), ( 495, 450, 17 ),

( 540, 0, 204 ), ( 540, 45, 187 ), ( 540, 90, 170 ), ( 540, 135, 153 ), ( 540, 180, 136 ), ( 540, 225, 119 ), ( 540, 270, 102 ), ( 540, 315, 85 ), ( 540, 360, 68 ), ( 540, 405, 51 ), ( 540, 450, 34 ), ( 540, 495, 17 ),

( 585, 0, 221 ), ( 585, 45, 204 ), ( 585, 90, 187 ), ( 585, 135, 170 ), ( 585, 180, 153 ), ( 585, 225, 136 ), ( 585, 270, 119 ), ( 585, 315, 102 ), ( 585, 360, 85 ), ( 585, 405, 68 ), ( 585, 450, 51 ), ( 585, 495, 34 ), ( 585, 540, 17 ),

( 630, 0, 238 ), ( 630, 45, 221 ), ( 630, 90, 204 ), ( 630, 135, 187 ), ( 630, 180, 170 ), ( 630, 225, 153 ), ( 630, 270, 136 ), ( 630, 315, 119 ), ( 630, 360, 102 ), ( 630, 405, 85 ), ( 630, 450, 68 ), ( 630, 495, 51 ), ( 630, 540, 34 ), ( 630, 585, 17 ),

...

}

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)