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

47/18 = (47-0)/18 = {

( 47, 0, 18 ),

( 94, 0, 36 ), ( 94, 47, 18 ),

( 141, 0, 54 ), ( 141, 47, 36 ), ( 141, 94, 18 ),

( 188, 0, 72 ), ( 188, 47, 54 ), ( 188, 94, 36 ), ( 188, 141, 18 ),

( 235, 0, 90 ), ( 235, 47, 72 ), ( 235, 94, 54 ), ( 235, 141, 36 ), ( 235, 188, 18 ),

( 282, 0, 108 ), ( 282, 47, 90 ), ( 282, 94, 72 ), ( 282, 141, 54 ), ( 282, 188, 36 ), ( 282, 235, 18 ),

( 329, 0, 126 ), ( 329, 47, 108 ), ( 329, 94, 90 ), ( 329, 141, 72 ), ( 329, 188, 54 ), ( 329, 235, 36 ), ( 329, 282, 18 ),

( 376, 0, 144 ), ( 376, 47, 126 ), ( 376, 94, 108 ), ( 376, 141, 90 ), ( 376, 188, 72 ), ( 376, 235, 54 ), ( 376, 282, 36 ), ( 376, 329, 18 ),

( 423, 0, 162 ), ( 423, 47, 144 ), ( 423, 94, 126 ), ( 423, 141, 108 ), ( 423, 188, 90 ), ( 423, 235, 72 ), ( 423, 282, 54 ), ( 423, 329, 36 ), ( 423, 376, 18 ),

( 470, 0, 180 ), ( 470, 47, 162 ), ( 470, 94, 144 ), ( 470, 141, 126 ), ( 470, 188, 108 ), ( 470, 235, 90 ), ( 470, 282, 72 ), ( 470, 329, 54 ), ( 470, 376, 36 ), ( 470, 423, 18 ),

( 517, 0, 198 ), ( 517, 47, 180 ), ( 517, 94, 162 ), ( 517, 141, 144 ), ( 517, 188, 126 ), ( 517, 235, 108 ), ( 517, 282, 90 ), ( 517, 329, 72 ), ( 517, 376, 54 ), ( 517, 423, 36 ), ( 517, 470, 18 ),

( 564, 0, 216 ), ( 564, 47, 198 ), ( 564, 94, 180 ), ( 564, 141, 162 ), ( 564, 188, 144 ), ( 564, 235, 126 ), ( 564, 282, 108 ), ( 564, 329, 90 ), ( 564, 376, 72 ), ( 564, 423, 54 ), ( 564, 470, 36 ), ( 564, 517, 18 ),

( 611, 0, 234 ), ( 611, 47, 216 ), ( 611, 94, 198 ), ( 611, 141, 180 ), ( 611, 188, 162 ), ( 611, 235, 144 ), ( 611, 282, 126 ), ( 611, 329, 108 ), ( 611, 376, 90 ), ( 611, 423, 72 ), ( 611, 470, 54 ), ( 611, 517, 36 ), ( 611, 564, 18 ),

( 658, 0, 252 ), ( 658, 47, 234 ), ( 658, 94, 216 ), ( 658, 141, 198 ), ( 658, 188, 180 ), ( 658, 235, 162 ), ( 658, 282, 144 ), ( 658, 329, 126 ), ( 658, 376, 108 ), ( 658, 423, 90 ), ( 658, 470, 72 ), ( 658, 517, 54 ), ( 658, 564, 36 ), ( 658, 611, 18 ),

...

}

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)