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

( 40, 0, 3 ),

( 80, 0, 6 ), ( 80, 40, 3 ),

( 120, 0, 9 ), ( 120, 40, 6 ), ( 120, 80, 3 ),

( 160, 0, 12 ), ( 160, 40, 9 ), ( 160, 80, 6 ), ( 160, 120, 3 ),

( 200, 0, 15 ), ( 200, 40, 12 ), ( 200, 80, 9 ), ( 200, 120, 6 ), ( 200, 160, 3 ),

( 240, 0, 18 ), ( 240, 40, 15 ), ( 240, 80, 12 ), ( 240, 120, 9 ), ( 240, 160, 6 ), ( 240, 200, 3 ),

( 280, 0, 21 ), ( 280, 40, 18 ), ( 280, 80, 15 ), ( 280, 120, 12 ), ( 280, 160, 9 ), ( 280, 200, 6 ), ( 280, 240, 3 ),

( 320, 0, 24 ), ( 320, 40, 21 ), ( 320, 80, 18 ), ( 320, 120, 15 ), ( 320, 160, 12 ), ( 320, 200, 9 ), ( 320, 240, 6 ), ( 320, 280, 3 ),

( 360, 0, 27 ), ( 360, 40, 24 ), ( 360, 80, 21 ), ( 360, 120, 18 ), ( 360, 160, 15 ), ( 360, 200, 12 ), ( 360, 240, 9 ), ( 360, 280, 6 ), ( 360, 320, 3 ),

( 400, 0, 30 ), ( 400, 40, 27 ), ( 400, 80, 24 ), ( 400, 120, 21 ), ( 400, 160, 18 ), ( 400, 200, 15 ), ( 400, 240, 12 ), ( 400, 280, 9 ), ( 400, 320, 6 ), ( 400, 360, 3 ),

( 440, 0, 33 ), ( 440, 40, 30 ), ( 440, 80, 27 ), ( 440, 120, 24 ), ( 440, 160, 21 ), ( 440, 200, 18 ), ( 440, 240, 15 ), ( 440, 280, 12 ), ( 440, 320, 9 ), ( 440, 360, 6 ), ( 440, 400, 3 ),

( 480, 0, 36 ), ( 480, 40, 33 ), ( 480, 80, 30 ), ( 480, 120, 27 ), ( 480, 160, 24 ), ( 480, 200, 21 ), ( 480, 240, 18 ), ( 480, 280, 15 ), ( 480, 320, 12 ), ( 480, 360, 9 ), ( 480, 400, 6 ), ( 480, 440, 3 ),

( 520, 0, 39 ), ( 520, 40, 36 ), ( 520, 80, 33 ), ( 520, 120, 30 ), ( 520, 160, 27 ), ( 520, 200, 24 ), ( 520, 240, 21 ), ( 520, 280, 18 ), ( 520, 320, 15 ), ( 520, 360, 12 ), ( 520, 400, 9 ), ( 520, 440, 6 ), ( 520, 480, 3 ),

( 560, 0, 42 ), ( 560, 40, 39 ), ( 560, 80, 36 ), ( 560, 120, 33 ), ( 560, 160, 30 ), ( 560, 200, 27 ), ( 560, 240, 24 ), ( 560, 280, 21 ), ( 560, 320, 18 ), ( 560, 360, 15 ), ( 560, 400, 12 ), ( 560, 440, 9 ), ( 560, 480, 6 ), ( 560, 520, 3 ),

...

}

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)