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

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

( 40, 0, 17 ),

( 80, 0, 34 ), ( 80, 40, 17 ),

( 120, 0, 51 ), ( 120, 40, 34 ), ( 120, 80, 17 ),

( 160, 0, 68 ), ( 160, 40, 51 ), ( 160, 80, 34 ), ( 160, 120, 17 ),

( 200, 0, 85 ), ( 200, 40, 68 ), ( 200, 80, 51 ), ( 200, 120, 34 ), ( 200, 160, 17 ),

( 240, 0, 102 ), ( 240, 40, 85 ), ( 240, 80, 68 ), ( 240, 120, 51 ), ( 240, 160, 34 ), ( 240, 200, 17 ),

( 280, 0, 119 ), ( 280, 40, 102 ), ( 280, 80, 85 ), ( 280, 120, 68 ), ( 280, 160, 51 ), ( 280, 200, 34 ), ( 280, 240, 17 ),

( 320, 0, 136 ), ( 320, 40, 119 ), ( 320, 80, 102 ), ( 320, 120, 85 ), ( 320, 160, 68 ), ( 320, 200, 51 ), ( 320, 240, 34 ), ( 320, 280, 17 ),

( 360, 0, 153 ), ( 360, 40, 136 ), ( 360, 80, 119 ), ( 360, 120, 102 ), ( 360, 160, 85 ), ( 360, 200, 68 ), ( 360, 240, 51 ), ( 360, 280, 34 ), ( 360, 320, 17 ),

( 400, 0, 170 ), ( 400, 40, 153 ), ( 400, 80, 136 ), ( 400, 120, 119 ), ( 400, 160, 102 ), ( 400, 200, 85 ), ( 400, 240, 68 ), ( 400, 280, 51 ), ( 400, 320, 34 ), ( 400, 360, 17 ),

( 440, 0, 187 ), ( 440, 40, 170 ), ( 440, 80, 153 ), ( 440, 120, 136 ), ( 440, 160, 119 ), ( 440, 200, 102 ), ( 440, 240, 85 ), ( 440, 280, 68 ), ( 440, 320, 51 ), ( 440, 360, 34 ), ( 440, 400, 17 ),

( 480, 0, 204 ), ( 480, 40, 187 ), ( 480, 80, 170 ), ( 480, 120, 153 ), ( 480, 160, 136 ), ( 480, 200, 119 ), ( 480, 240, 102 ), ( 480, 280, 85 ), ( 480, 320, 68 ), ( 480, 360, 51 ), ( 480, 400, 34 ), ( 480, 440, 17 ),

( 520, 0, 221 ), ( 520, 40, 204 ), ( 520, 80, 187 ), ( 520, 120, 170 ), ( 520, 160, 153 ), ( 520, 200, 136 ), ( 520, 240, 119 ), ( 520, 280, 102 ), ( 520, 320, 85 ), ( 520, 360, 68 ), ( 520, 400, 51 ), ( 520, 440, 34 ), ( 520, 480, 17 ),

( 560, 0, 238 ), ( 560, 40, 221 ), ( 560, 80, 204 ), ( 560, 120, 187 ), ( 560, 160, 170 ), ( 560, 200, 153 ), ( 560, 240, 136 ), ( 560, 280, 119 ), ( 560, 320, 102 ), ( 560, 360, 85 ), ( 560, 400, 68 ), ( 560, 440, 51 ), ( 560, 480, 34 ), ( 560, 520, 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)