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

( 40, 0, 13 ),

( 80, 0, 26 ), ( 80, 40, 13 ),

( 120, 0, 39 ), ( 120, 40, 26 ), ( 120, 80, 13 ),

( 160, 0, 52 ), ( 160, 40, 39 ), ( 160, 80, 26 ), ( 160, 120, 13 ),

( 200, 0, 65 ), ( 200, 40, 52 ), ( 200, 80, 39 ), ( 200, 120, 26 ), ( 200, 160, 13 ),

( 240, 0, 78 ), ( 240, 40, 65 ), ( 240, 80, 52 ), ( 240, 120, 39 ), ( 240, 160, 26 ), ( 240, 200, 13 ),

( 280, 0, 91 ), ( 280, 40, 78 ), ( 280, 80, 65 ), ( 280, 120, 52 ), ( 280, 160, 39 ), ( 280, 200, 26 ), ( 280, 240, 13 ),

( 320, 0, 104 ), ( 320, 40, 91 ), ( 320, 80, 78 ), ( 320, 120, 65 ), ( 320, 160, 52 ), ( 320, 200, 39 ), ( 320, 240, 26 ), ( 320, 280, 13 ),

( 360, 0, 117 ), ( 360, 40, 104 ), ( 360, 80, 91 ), ( 360, 120, 78 ), ( 360, 160, 65 ), ( 360, 200, 52 ), ( 360, 240, 39 ), ( 360, 280, 26 ), ( 360, 320, 13 ),

( 400, 0, 130 ), ( 400, 40, 117 ), ( 400, 80, 104 ), ( 400, 120, 91 ), ( 400, 160, 78 ), ( 400, 200, 65 ), ( 400, 240, 52 ), ( 400, 280, 39 ), ( 400, 320, 26 ), ( 400, 360, 13 ),

( 440, 0, 143 ), ( 440, 40, 130 ), ( 440, 80, 117 ), ( 440, 120, 104 ), ( 440, 160, 91 ), ( 440, 200, 78 ), ( 440, 240, 65 ), ( 440, 280, 52 ), ( 440, 320, 39 ), ( 440, 360, 26 ), ( 440, 400, 13 ),

( 480, 0, 156 ), ( 480, 40, 143 ), ( 480, 80, 130 ), ( 480, 120, 117 ), ( 480, 160, 104 ), ( 480, 200, 91 ), ( 480, 240, 78 ), ( 480, 280, 65 ), ( 480, 320, 52 ), ( 480, 360, 39 ), ( 480, 400, 26 ), ( 480, 440, 13 ),

( 520, 0, 169 ), ( 520, 40, 156 ), ( 520, 80, 143 ), ( 520, 120, 130 ), ( 520, 160, 117 ), ( 520, 200, 104 ), ( 520, 240, 91 ), ( 520, 280, 78 ), ( 520, 320, 65 ), ( 520, 360, 52 ), ( 520, 400, 39 ), ( 520, 440, 26 ), ( 520, 480, 13 ),

( 560, 0, 182 ), ( 560, 40, 169 ), ( 560, 80, 156 ), ( 560, 120, 143 ), ( 560, 160, 130 ), ( 560, 200, 117 ), ( 560, 240, 104 ), ( 560, 280, 91 ), ( 560, 320, 78 ), ( 560, 360, 65 ), ( 560, 400, 52 ), ( 560, 440, 39 ), ( 560, 480, 26 ), ( 560, 520, 13 ),

...

}

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)