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

20/3 = (20-0)/3 = {

( 20, 0, 3 ),

( 40, 0, 6 ), ( 40, 20, 3 ),

( 60, 0, 9 ), ( 60, 20, 6 ), ( 60, 40, 3 ),

( 80, 0, 12 ), ( 80, 20, 9 ), ( 80, 40, 6 ), ( 80, 60, 3 ),

( 100, 0, 15 ), ( 100, 20, 12 ), ( 100, 40, 9 ), ( 100, 60, 6 ), ( 100, 80, 3 ),

( 120, 0, 18 ), ( 120, 20, 15 ), ( 120, 40, 12 ), ( 120, 60, 9 ), ( 120, 80, 6 ), ( 120, 100, 3 ),

( 140, 0, 21 ), ( 140, 20, 18 ), ( 140, 40, 15 ), ( 140, 60, 12 ), ( 140, 80, 9 ), ( 140, 100, 6 ), ( 140, 120, 3 ),

( 160, 0, 24 ), ( 160, 20, 21 ), ( 160, 40, 18 ), ( 160, 60, 15 ), ( 160, 80, 12 ), ( 160, 100, 9 ), ( 160, 120, 6 ), ( 160, 140, 3 ),

( 180, 0, 27 ), ( 180, 20, 24 ), ( 180, 40, 21 ), ( 180, 60, 18 ), ( 180, 80, 15 ), ( 180, 100, 12 ), ( 180, 120, 9 ), ( 180, 140, 6 ), ( 180, 160, 3 ),

( 200, 0, 30 ), ( 200, 20, 27 ), ( 200, 40, 24 ), ( 200, 60, 21 ), ( 200, 80, 18 ), ( 200, 100, 15 ), ( 200, 120, 12 ), ( 200, 140, 9 ), ( 200, 160, 6 ), ( 200, 180, 3 ),

( 220, 0, 33 ), ( 220, 20, 30 ), ( 220, 40, 27 ), ( 220, 60, 24 ), ( 220, 80, 21 ), ( 220, 100, 18 ), ( 220, 120, 15 ), ( 220, 140, 12 ), ( 220, 160, 9 ), ( 220, 180, 6 ), ( 220, 200, 3 ),

( 240, 0, 36 ), ( 240, 20, 33 ), ( 240, 40, 30 ), ( 240, 60, 27 ), ( 240, 80, 24 ), ( 240, 100, 21 ), ( 240, 120, 18 ), ( 240, 140, 15 ), ( 240, 160, 12 ), ( 240, 180, 9 ), ( 240, 200, 6 ), ( 240, 220, 3 ),

( 260, 0, 39 ), ( 260, 20, 36 ), ( 260, 40, 33 ), ( 260, 60, 30 ), ( 260, 80, 27 ), ( 260, 100, 24 ), ( 260, 120, 21 ), ( 260, 140, 18 ), ( 260, 160, 15 ), ( 260, 180, 12 ), ( 260, 200, 9 ), ( 260, 220, 6 ), ( 260, 240, 3 ),

( 280, 0, 42 ), ( 280, 20, 39 ), ( 280, 40, 36 ), ( 280, 60, 33 ), ( 280, 80, 30 ), ( 280, 100, 27 ), ( 280, 120, 24 ), ( 280, 140, 21 ), ( 280, 160, 18 ), ( 280, 180, 15 ), ( 280, 200, 12 ), ( 280, 220, 9 ), ( 280, 240, 6 ), ( 280, 260, 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)