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

( 40, 0, 21 ),

( 80, 0, 42 ), ( 80, 40, 21 ),

( 120, 0, 63 ), ( 120, 40, 42 ), ( 120, 80, 21 ),

( 160, 0, 84 ), ( 160, 40, 63 ), ( 160, 80, 42 ), ( 160, 120, 21 ),

( 200, 0, 105 ), ( 200, 40, 84 ), ( 200, 80, 63 ), ( 200, 120, 42 ), ( 200, 160, 21 ),

( 240, 0, 126 ), ( 240, 40, 105 ), ( 240, 80, 84 ), ( 240, 120, 63 ), ( 240, 160, 42 ), ( 240, 200, 21 ),

( 280, 0, 147 ), ( 280, 40, 126 ), ( 280, 80, 105 ), ( 280, 120, 84 ), ( 280, 160, 63 ), ( 280, 200, 42 ), ( 280, 240, 21 ),

( 320, 0, 168 ), ( 320, 40, 147 ), ( 320, 80, 126 ), ( 320, 120, 105 ), ( 320, 160, 84 ), ( 320, 200, 63 ), ( 320, 240, 42 ), ( 320, 280, 21 ),

( 360, 0, 189 ), ( 360, 40, 168 ), ( 360, 80, 147 ), ( 360, 120, 126 ), ( 360, 160, 105 ), ( 360, 200, 84 ), ( 360, 240, 63 ), ( 360, 280, 42 ), ( 360, 320, 21 ),

( 400, 0, 210 ), ( 400, 40, 189 ), ( 400, 80, 168 ), ( 400, 120, 147 ), ( 400, 160, 126 ), ( 400, 200, 105 ), ( 400, 240, 84 ), ( 400, 280, 63 ), ( 400, 320, 42 ), ( 400, 360, 21 ),

( 440, 0, 231 ), ( 440, 40, 210 ), ( 440, 80, 189 ), ( 440, 120, 168 ), ( 440, 160, 147 ), ( 440, 200, 126 ), ( 440, 240, 105 ), ( 440, 280, 84 ), ( 440, 320, 63 ), ( 440, 360, 42 ), ( 440, 400, 21 ),

( 480, 0, 252 ), ( 480, 40, 231 ), ( 480, 80, 210 ), ( 480, 120, 189 ), ( 480, 160, 168 ), ( 480, 200, 147 ), ( 480, 240, 126 ), ( 480, 280, 105 ), ( 480, 320, 84 ), ( 480, 360, 63 ), ( 480, 400, 42 ), ( 480, 440, 21 ),

( 520, 0, 273 ), ( 520, 40, 252 ), ( 520, 80, 231 ), ( 520, 120, 210 ), ( 520, 160, 189 ), ( 520, 200, 168 ), ( 520, 240, 147 ), ( 520, 280, 126 ), ( 520, 320, 105 ), ( 520, 360, 84 ), ( 520, 400, 63 ), ( 520, 440, 42 ), ( 520, 480, 21 ),

( 560, 0, 294 ), ( 560, 40, 273 ), ( 560, 80, 252 ), ( 560, 120, 231 ), ( 560, 160, 210 ), ( 560, 200, 189 ), ( 560, 240, 168 ), ( 560, 280, 147 ), ( 560, 320, 126 ), ( 560, 360, 105 ), ( 560, 400, 84 ), ( 560, 440, 63 ), ( 560, 480, 42 ), ( 560, 520, 21 ),

...

}

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)