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

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

( 40, 0, 19 ),

( 80, 0, 38 ), ( 80, 40, 19 ),

( 120, 0, 57 ), ( 120, 40, 38 ), ( 120, 80, 19 ),

( 160, 0, 76 ), ( 160, 40, 57 ), ( 160, 80, 38 ), ( 160, 120, 19 ),

( 200, 0, 95 ), ( 200, 40, 76 ), ( 200, 80, 57 ), ( 200, 120, 38 ), ( 200, 160, 19 ),

( 240, 0, 114 ), ( 240, 40, 95 ), ( 240, 80, 76 ), ( 240, 120, 57 ), ( 240, 160, 38 ), ( 240, 200, 19 ),

( 280, 0, 133 ), ( 280, 40, 114 ), ( 280, 80, 95 ), ( 280, 120, 76 ), ( 280, 160, 57 ), ( 280, 200, 38 ), ( 280, 240, 19 ),

( 320, 0, 152 ), ( 320, 40, 133 ), ( 320, 80, 114 ), ( 320, 120, 95 ), ( 320, 160, 76 ), ( 320, 200, 57 ), ( 320, 240, 38 ), ( 320, 280, 19 ),

( 360, 0, 171 ), ( 360, 40, 152 ), ( 360, 80, 133 ), ( 360, 120, 114 ), ( 360, 160, 95 ), ( 360, 200, 76 ), ( 360, 240, 57 ), ( 360, 280, 38 ), ( 360, 320, 19 ),

( 400, 0, 190 ), ( 400, 40, 171 ), ( 400, 80, 152 ), ( 400, 120, 133 ), ( 400, 160, 114 ), ( 400, 200, 95 ), ( 400, 240, 76 ), ( 400, 280, 57 ), ( 400, 320, 38 ), ( 400, 360, 19 ),

( 440, 0, 209 ), ( 440, 40, 190 ), ( 440, 80, 171 ), ( 440, 120, 152 ), ( 440, 160, 133 ), ( 440, 200, 114 ), ( 440, 240, 95 ), ( 440, 280, 76 ), ( 440, 320, 57 ), ( 440, 360, 38 ), ( 440, 400, 19 ),

( 480, 0, 228 ), ( 480, 40, 209 ), ( 480, 80, 190 ), ( 480, 120, 171 ), ( 480, 160, 152 ), ( 480, 200, 133 ), ( 480, 240, 114 ), ( 480, 280, 95 ), ( 480, 320, 76 ), ( 480, 360, 57 ), ( 480, 400, 38 ), ( 480, 440, 19 ),

( 520, 0, 247 ), ( 520, 40, 228 ), ( 520, 80, 209 ), ( 520, 120, 190 ), ( 520, 160, 171 ), ( 520, 200, 152 ), ( 520, 240, 133 ), ( 520, 280, 114 ), ( 520, 320, 95 ), ( 520, 360, 76 ), ( 520, 400, 57 ), ( 520, 440, 38 ), ( 520, 480, 19 ),

( 560, 0, 266 ), ( 560, 40, 247 ), ( 560, 80, 228 ), ( 560, 120, 209 ), ( 560, 160, 190 ), ( 560, 200, 171 ), ( 560, 240, 152 ), ( 560, 280, 133 ), ( 560, 320, 114 ), ( 560, 360, 95 ), ( 560, 400, 76 ), ( 560, 440, 57 ), ( 560, 480, 38 ), ( 560, 520, 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)