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

( 45, 0, 29 ),

( 90, 0, 58 ), ( 90, 45, 29 ),

( 135, 0, 87 ), ( 135, 45, 58 ), ( 135, 90, 29 ),

( 180, 0, 116 ), ( 180, 45, 87 ), ( 180, 90, 58 ), ( 180, 135, 29 ),

( 225, 0, 145 ), ( 225, 45, 116 ), ( 225, 90, 87 ), ( 225, 135, 58 ), ( 225, 180, 29 ),

( 270, 0, 174 ), ( 270, 45, 145 ), ( 270, 90, 116 ), ( 270, 135, 87 ), ( 270, 180, 58 ), ( 270, 225, 29 ),

( 315, 0, 203 ), ( 315, 45, 174 ), ( 315, 90, 145 ), ( 315, 135, 116 ), ( 315, 180, 87 ), ( 315, 225, 58 ), ( 315, 270, 29 ),

( 360, 0, 232 ), ( 360, 45, 203 ), ( 360, 90, 174 ), ( 360, 135, 145 ), ( 360, 180, 116 ), ( 360, 225, 87 ), ( 360, 270, 58 ), ( 360, 315, 29 ),

( 405, 0, 261 ), ( 405, 45, 232 ), ( 405, 90, 203 ), ( 405, 135, 174 ), ( 405, 180, 145 ), ( 405, 225, 116 ), ( 405, 270, 87 ), ( 405, 315, 58 ), ( 405, 360, 29 ),

( 450, 0, 290 ), ( 450, 45, 261 ), ( 450, 90, 232 ), ( 450, 135, 203 ), ( 450, 180, 174 ), ( 450, 225, 145 ), ( 450, 270, 116 ), ( 450, 315, 87 ), ( 450, 360, 58 ), ( 450, 405, 29 ),

( 495, 0, 319 ), ( 495, 45, 290 ), ( 495, 90, 261 ), ( 495, 135, 232 ), ( 495, 180, 203 ), ( 495, 225, 174 ), ( 495, 270, 145 ), ( 495, 315, 116 ), ( 495, 360, 87 ), ( 495, 405, 58 ), ( 495, 450, 29 ),

( 540, 0, 348 ), ( 540, 45, 319 ), ( 540, 90, 290 ), ( 540, 135, 261 ), ( 540, 180, 232 ), ( 540, 225, 203 ), ( 540, 270, 174 ), ( 540, 315, 145 ), ( 540, 360, 116 ), ( 540, 405, 87 ), ( 540, 450, 58 ), ( 540, 495, 29 ),

( 585, 0, 377 ), ( 585, 45, 348 ), ( 585, 90, 319 ), ( 585, 135, 290 ), ( 585, 180, 261 ), ( 585, 225, 232 ), ( 585, 270, 203 ), ( 585, 315, 174 ), ( 585, 360, 145 ), ( 585, 405, 116 ), ( 585, 450, 87 ), ( 585, 495, 58 ), ( 585, 540, 29 ),

( 630, 0, 406 ), ( 630, 45, 377 ), ( 630, 90, 348 ), ( 630, 135, 319 ), ( 630, 180, 290 ), ( 630, 225, 261 ), ( 630, 270, 232 ), ( 630, 315, 203 ), ( 630, 360, 174 ), ( 630, 405, 145 ), ( 630, 450, 116 ), ( 630, 495, 87 ), ( 630, 540, 58 ), ( 630, 585, 29 ),

...

}

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)