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

( 47, 0, 32 ),

( 94, 0, 64 ), ( 94, 47, 32 ),

( 141, 0, 96 ), ( 141, 47, 64 ), ( 141, 94, 32 ),

( 188, 0, 128 ), ( 188, 47, 96 ), ( 188, 94, 64 ), ( 188, 141, 32 ),

( 235, 0, 160 ), ( 235, 47, 128 ), ( 235, 94, 96 ), ( 235, 141, 64 ), ( 235, 188, 32 ),

( 282, 0, 192 ), ( 282, 47, 160 ), ( 282, 94, 128 ), ( 282, 141, 96 ), ( 282, 188, 64 ), ( 282, 235, 32 ),

( 329, 0, 224 ), ( 329, 47, 192 ), ( 329, 94, 160 ), ( 329, 141, 128 ), ( 329, 188, 96 ), ( 329, 235, 64 ), ( 329, 282, 32 ),

( 376, 0, 256 ), ( 376, 47, 224 ), ( 376, 94, 192 ), ( 376, 141, 160 ), ( 376, 188, 128 ), ( 376, 235, 96 ), ( 376, 282, 64 ), ( 376, 329, 32 ),

( 423, 0, 288 ), ( 423, 47, 256 ), ( 423, 94, 224 ), ( 423, 141, 192 ), ( 423, 188, 160 ), ( 423, 235, 128 ), ( 423, 282, 96 ), ( 423, 329, 64 ), ( 423, 376, 32 ),

( 470, 0, 320 ), ( 470, 47, 288 ), ( 470, 94, 256 ), ( 470, 141, 224 ), ( 470, 188, 192 ), ( 470, 235, 160 ), ( 470, 282, 128 ), ( 470, 329, 96 ), ( 470, 376, 64 ), ( 470, 423, 32 ),

( 517, 0, 352 ), ( 517, 47, 320 ), ( 517, 94, 288 ), ( 517, 141, 256 ), ( 517, 188, 224 ), ( 517, 235, 192 ), ( 517, 282, 160 ), ( 517, 329, 128 ), ( 517, 376, 96 ), ( 517, 423, 64 ), ( 517, 470, 32 ),

( 564, 0, 384 ), ( 564, 47, 352 ), ( 564, 94, 320 ), ( 564, 141, 288 ), ( 564, 188, 256 ), ( 564, 235, 224 ), ( 564, 282, 192 ), ( 564, 329, 160 ), ( 564, 376, 128 ), ( 564, 423, 96 ), ( 564, 470, 64 ), ( 564, 517, 32 ),

( 611, 0, 416 ), ( 611, 47, 384 ), ( 611, 94, 352 ), ( 611, 141, 320 ), ( 611, 188, 288 ), ( 611, 235, 256 ), ( 611, 282, 224 ), ( 611, 329, 192 ), ( 611, 376, 160 ), ( 611, 423, 128 ), ( 611, 470, 96 ), ( 611, 517, 64 ), ( 611, 564, 32 ),

( 658, 0, 448 ), ( 658, 47, 416 ), ( 658, 94, 384 ), ( 658, 141, 352 ), ( 658, 188, 320 ), ( 658, 235, 288 ), ( 658, 282, 256 ), ( 658, 329, 224 ), ( 658, 376, 192 ), ( 658, 423, 160 ), ( 658, 470, 128 ), ( 658, 517, 96 ), ( 658, 564, 64 ), ( 658, 611, 32 ),

...

}

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)