The rational number 40/27 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.

40/27 = (40-0)/27 = {

( 40, 0, 27 ),

( 80, 0, 54 ), ( 80, 40, 27 ),

( 120, 0, 81 ), ( 120, 40, 54 ), ( 120, 80, 27 ),

( 160, 0, 108 ), ( 160, 40, 81 ), ( 160, 80, 54 ), ( 160, 120, 27 ),

( 200, 0, 135 ), ( 200, 40, 108 ), ( 200, 80, 81 ), ( 200, 120, 54 ), ( 200, 160, 27 ),

( 240, 0, 162 ), ( 240, 40, 135 ), ( 240, 80, 108 ), ( 240, 120, 81 ), ( 240, 160, 54 ), ( 240, 200, 27 ),

( 280, 0, 189 ), ( 280, 40, 162 ), ( 280, 80, 135 ), ( 280, 120, 108 ), ( 280, 160, 81 ), ( 280, 200, 54 ), ( 280, 240, 27 ),

( 320, 0, 216 ), ( 320, 40, 189 ), ( 320, 80, 162 ), ( 320, 120, 135 ), ( 320, 160, 108 ), ( 320, 200, 81 ), ( 320, 240, 54 ), ( 320, 280, 27 ),

( 360, 0, 243 ), ( 360, 40, 216 ), ( 360, 80, 189 ), ( 360, 120, 162 ), ( 360, 160, 135 ), ( 360, 200, 108 ), ( 360, 240, 81 ), ( 360, 280, 54 ), ( 360, 320, 27 ),

( 400, 0, 270 ), ( 400, 40, 243 ), ( 400, 80, 216 ), ( 400, 120, 189 ), ( 400, 160, 162 ), ( 400, 200, 135 ), ( 400, 240, 108 ), ( 400, 280, 81 ), ( 400, 320, 54 ), ( 400, 360, 27 ),

( 440, 0, 297 ), ( 440, 40, 270 ), ( 440, 80, 243 ), ( 440, 120, 216 ), ( 440, 160, 189 ), ( 440, 200, 162 ), ( 440, 240, 135 ), ( 440, 280, 108 ), ( 440, 320, 81 ), ( 440, 360, 54 ), ( 440, 400, 27 ),

( 480, 0, 324 ), ( 480, 40, 297 ), ( 480, 80, 270 ), ( 480, 120, 243 ), ( 480, 160, 216 ), ( 480, 200, 189 ), ( 480, 240, 162 ), ( 480, 280, 135 ), ( 480, 320, 108 ), ( 480, 360, 81 ), ( 480, 400, 54 ), ( 480, 440, 27 ),

( 520, 0, 351 ), ( 520, 40, 324 ), ( 520, 80, 297 ), ( 520, 120, 270 ), ( 520, 160, 243 ), ( 520, 200, 216 ), ( 520, 240, 189 ), ( 520, 280, 162 ), ( 520, 320, 135 ), ( 520, 360, 108 ), ( 520, 400, 81 ), ( 520, 440, 54 ), ( 520, 480, 27 ),

( 560, 0, 378 ), ( 560, 40, 351 ), ( 560, 80, 324 ), ( 560, 120, 297 ), ( 560, 160, 270 ), ( 560, 200, 243 ), ( 560, 240, 216 ), ( 560, 280, 189 ), ( 560, 320, 162 ), ( 560, 360, 135 ), ( 560, 400, 108 ), ( 560, 440, 81 ), ( 560, 480, 54 ), ( 560, 520, 27 ),

...

}

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)