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

43/5 = (43-0)/5 = {

( 43, 0, 5 ),

( 86, 0, 10 ), ( 86, 43, 5 ),

( 129, 0, 15 ), ( 129, 43, 10 ), ( 129, 86, 5 ),

( 172, 0, 20 ), ( 172, 43, 15 ), ( 172, 86, 10 ), ( 172, 129, 5 ),

( 215, 0, 25 ), ( 215, 43, 20 ), ( 215, 86, 15 ), ( 215, 129, 10 ), ( 215, 172, 5 ),

( 258, 0, 30 ), ( 258, 43, 25 ), ( 258, 86, 20 ), ( 258, 129, 15 ), ( 258, 172, 10 ), ( 258, 215, 5 ),

( 301, 0, 35 ), ( 301, 43, 30 ), ( 301, 86, 25 ), ( 301, 129, 20 ), ( 301, 172, 15 ), ( 301, 215, 10 ), ( 301, 258, 5 ),

( 344, 0, 40 ), ( 344, 43, 35 ), ( 344, 86, 30 ), ( 344, 129, 25 ), ( 344, 172, 20 ), ( 344, 215, 15 ), ( 344, 258, 10 ), ( 344, 301, 5 ),

( 387, 0, 45 ), ( 387, 43, 40 ), ( 387, 86, 35 ), ( 387, 129, 30 ), ( 387, 172, 25 ), ( 387, 215, 20 ), ( 387, 258, 15 ), ( 387, 301, 10 ), ( 387, 344, 5 ),

( 430, 0, 50 ), ( 430, 43, 45 ), ( 430, 86, 40 ), ( 430, 129, 35 ), ( 430, 172, 30 ), ( 430, 215, 25 ), ( 430, 258, 20 ), ( 430, 301, 15 ), ( 430, 344, 10 ), ( 430, 387, 5 ),

( 473, 0, 55 ), ( 473, 43, 50 ), ( 473, 86, 45 ), ( 473, 129, 40 ), ( 473, 172, 35 ), ( 473, 215, 30 ), ( 473, 258, 25 ), ( 473, 301, 20 ), ( 473, 344, 15 ), ( 473, 387, 10 ), ( 473, 430, 5 ),

( 516, 0, 60 ), ( 516, 43, 55 ), ( 516, 86, 50 ), ( 516, 129, 45 ), ( 516, 172, 40 ), ( 516, 215, 35 ), ( 516, 258, 30 ), ( 516, 301, 25 ), ( 516, 344, 20 ), ( 516, 387, 15 ), ( 516, 430, 10 ), ( 516, 473, 5 ),

( 559, 0, 65 ), ( 559, 43, 60 ), ( 559, 86, 55 ), ( 559, 129, 50 ), ( 559, 172, 45 ), ( 559, 215, 40 ), ( 559, 258, 35 ), ( 559, 301, 30 ), ( 559, 344, 25 ), ( 559, 387, 20 ), ( 559, 430, 15 ), ( 559, 473, 10 ), ( 559, 516, 5 ),

( 602, 0, 70 ), ( 602, 43, 65 ), ( 602, 86, 60 ), ( 602, 129, 55 ), ( 602, 172, 50 ), ( 602, 215, 45 ), ( 602, 258, 40 ), ( 602, 301, 35 ), ( 602, 344, 30 ), ( 602, 387, 25 ), ( 602, 430, 20 ), ( 602, 473, 15 ), ( 602, 516, 10 ), ( 602, 559, 5 ),

...

}

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)