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

( 47, 0, 16 ),

( 94, 0, 32 ), ( 94, 47, 16 ),

( 141, 0, 48 ), ( 141, 47, 32 ), ( 141, 94, 16 ),

( 188, 0, 64 ), ( 188, 47, 48 ), ( 188, 94, 32 ), ( 188, 141, 16 ),

( 235, 0, 80 ), ( 235, 47, 64 ), ( 235, 94, 48 ), ( 235, 141, 32 ), ( 235, 188, 16 ),

( 282, 0, 96 ), ( 282, 47, 80 ), ( 282, 94, 64 ), ( 282, 141, 48 ), ( 282, 188, 32 ), ( 282, 235, 16 ),

( 329, 0, 112 ), ( 329, 47, 96 ), ( 329, 94, 80 ), ( 329, 141, 64 ), ( 329, 188, 48 ), ( 329, 235, 32 ), ( 329, 282, 16 ),

( 376, 0, 128 ), ( 376, 47, 112 ), ( 376, 94, 96 ), ( 376, 141, 80 ), ( 376, 188, 64 ), ( 376, 235, 48 ), ( 376, 282, 32 ), ( 376, 329, 16 ),

( 423, 0, 144 ), ( 423, 47, 128 ), ( 423, 94, 112 ), ( 423, 141, 96 ), ( 423, 188, 80 ), ( 423, 235, 64 ), ( 423, 282, 48 ), ( 423, 329, 32 ), ( 423, 376, 16 ),

( 470, 0, 160 ), ( 470, 47, 144 ), ( 470, 94, 128 ), ( 470, 141, 112 ), ( 470, 188, 96 ), ( 470, 235, 80 ), ( 470, 282, 64 ), ( 470, 329, 48 ), ( 470, 376, 32 ), ( 470, 423, 16 ),

( 517, 0, 176 ), ( 517, 47, 160 ), ( 517, 94, 144 ), ( 517, 141, 128 ), ( 517, 188, 112 ), ( 517, 235, 96 ), ( 517, 282, 80 ), ( 517, 329, 64 ), ( 517, 376, 48 ), ( 517, 423, 32 ), ( 517, 470, 16 ),

( 564, 0, 192 ), ( 564, 47, 176 ), ( 564, 94, 160 ), ( 564, 141, 144 ), ( 564, 188, 128 ), ( 564, 235, 112 ), ( 564, 282, 96 ), ( 564, 329, 80 ), ( 564, 376, 64 ), ( 564, 423, 48 ), ( 564, 470, 32 ), ( 564, 517, 16 ),

( 611, 0, 208 ), ( 611, 47, 192 ), ( 611, 94, 176 ), ( 611, 141, 160 ), ( 611, 188, 144 ), ( 611, 235, 128 ), ( 611, 282, 112 ), ( 611, 329, 96 ), ( 611, 376, 80 ), ( 611, 423, 64 ), ( 611, 470, 48 ), ( 611, 517, 32 ), ( 611, 564, 16 ),

( 658, 0, 224 ), ( 658, 47, 208 ), ( 658, 94, 192 ), ( 658, 141, 176 ), ( 658, 188, 160 ), ( 658, 235, 144 ), ( 658, 282, 128 ), ( 658, 329, 112 ), ( 658, 376, 96 ), ( 658, 423, 80 ), ( 658, 470, 64 ), ( 658, 517, 48 ), ( 658, 564, 32 ), ( 658, 611, 16 ),

...

}

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)