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

29/14 = (29-0)/14 = {

( 29, 0, 14 ),

( 58, 0, 28 ), ( 58, 29, 14 ),

( 87, 0, 42 ), ( 87, 29, 28 ), ( 87, 58, 14 ),

( 116, 0, 56 ), ( 116, 29, 42 ), ( 116, 58, 28 ), ( 116, 87, 14 ),

( 145, 0, 70 ), ( 145, 29, 56 ), ( 145, 58, 42 ), ( 145, 87, 28 ), ( 145, 116, 14 ),

( 174, 0, 84 ), ( 174, 29, 70 ), ( 174, 58, 56 ), ( 174, 87, 42 ), ( 174, 116, 28 ), ( 174, 145, 14 ),

( 203, 0, 98 ), ( 203, 29, 84 ), ( 203, 58, 70 ), ( 203, 87, 56 ), ( 203, 116, 42 ), ( 203, 145, 28 ), ( 203, 174, 14 ),

( 232, 0, 112 ), ( 232, 29, 98 ), ( 232, 58, 84 ), ( 232, 87, 70 ), ( 232, 116, 56 ), ( 232, 145, 42 ), ( 232, 174, 28 ), ( 232, 203, 14 ),

( 261, 0, 126 ), ( 261, 29, 112 ), ( 261, 58, 98 ), ( 261, 87, 84 ), ( 261, 116, 70 ), ( 261, 145, 56 ), ( 261, 174, 42 ), ( 261, 203, 28 ), ( 261, 232, 14 ),

( 290, 0, 140 ), ( 290, 29, 126 ), ( 290, 58, 112 ), ( 290, 87, 98 ), ( 290, 116, 84 ), ( 290, 145, 70 ), ( 290, 174, 56 ), ( 290, 203, 42 ), ( 290, 232, 28 ), ( 290, 261, 14 ),

( 319, 0, 154 ), ( 319, 29, 140 ), ( 319, 58, 126 ), ( 319, 87, 112 ), ( 319, 116, 98 ), ( 319, 145, 84 ), ( 319, 174, 70 ), ( 319, 203, 56 ), ( 319, 232, 42 ), ( 319, 261, 28 ), ( 319, 290, 14 ),

( 348, 0, 168 ), ( 348, 29, 154 ), ( 348, 58, 140 ), ( 348, 87, 126 ), ( 348, 116, 112 ), ( 348, 145, 98 ), ( 348, 174, 84 ), ( 348, 203, 70 ), ( 348, 232, 56 ), ( 348, 261, 42 ), ( 348, 290, 28 ), ( 348, 319, 14 ),

( 377, 0, 182 ), ( 377, 29, 168 ), ( 377, 58, 154 ), ( 377, 87, 140 ), ( 377, 116, 126 ), ( 377, 145, 112 ), ( 377, 174, 98 ), ( 377, 203, 84 ), ( 377, 232, 70 ), ( 377, 261, 56 ), ( 377, 290, 42 ), ( 377, 319, 28 ), ( 377, 348, 14 ),

( 406, 0, 196 ), ( 406, 29, 182 ), ( 406, 58, 168 ), ( 406, 87, 154 ), ( 406, 116, 140 ), ( 406, 145, 126 ), ( 406, 174, 112 ), ( 406, 203, 98 ), ( 406, 232, 84 ), ( 406, 261, 70 ), ( 406, 290, 56 ), ( 406, 319, 42 ), ( 406, 348, 28 ), ( 406, 377, 14 ),

...

}

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)