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

( 47, 0, 31 ),

( 94, 0, 62 ), ( 94, 47, 31 ),

( 141, 0, 93 ), ( 141, 47, 62 ), ( 141, 94, 31 ),

( 188, 0, 124 ), ( 188, 47, 93 ), ( 188, 94, 62 ), ( 188, 141, 31 ),

( 235, 0, 155 ), ( 235, 47, 124 ), ( 235, 94, 93 ), ( 235, 141, 62 ), ( 235, 188, 31 ),

( 282, 0, 186 ), ( 282, 47, 155 ), ( 282, 94, 124 ), ( 282, 141, 93 ), ( 282, 188, 62 ), ( 282, 235, 31 ),

( 329, 0, 217 ), ( 329, 47, 186 ), ( 329, 94, 155 ), ( 329, 141, 124 ), ( 329, 188, 93 ), ( 329, 235, 62 ), ( 329, 282, 31 ),

( 376, 0, 248 ), ( 376, 47, 217 ), ( 376, 94, 186 ), ( 376, 141, 155 ), ( 376, 188, 124 ), ( 376, 235, 93 ), ( 376, 282, 62 ), ( 376, 329, 31 ),

( 423, 0, 279 ), ( 423, 47, 248 ), ( 423, 94, 217 ), ( 423, 141, 186 ), ( 423, 188, 155 ), ( 423, 235, 124 ), ( 423, 282, 93 ), ( 423, 329, 62 ), ( 423, 376, 31 ),

( 470, 0, 310 ), ( 470, 47, 279 ), ( 470, 94, 248 ), ( 470, 141, 217 ), ( 470, 188, 186 ), ( 470, 235, 155 ), ( 470, 282, 124 ), ( 470, 329, 93 ), ( 470, 376, 62 ), ( 470, 423, 31 ),

( 517, 0, 341 ), ( 517, 47, 310 ), ( 517, 94, 279 ), ( 517, 141, 248 ), ( 517, 188, 217 ), ( 517, 235, 186 ), ( 517, 282, 155 ), ( 517, 329, 124 ), ( 517, 376, 93 ), ( 517, 423, 62 ), ( 517, 470, 31 ),

( 564, 0, 372 ), ( 564, 47, 341 ), ( 564, 94, 310 ), ( 564, 141, 279 ), ( 564, 188, 248 ), ( 564, 235, 217 ), ( 564, 282, 186 ), ( 564, 329, 155 ), ( 564, 376, 124 ), ( 564, 423, 93 ), ( 564, 470, 62 ), ( 564, 517, 31 ),

( 611, 0, 403 ), ( 611, 47, 372 ), ( 611, 94, 341 ), ( 611, 141, 310 ), ( 611, 188, 279 ), ( 611, 235, 248 ), ( 611, 282, 217 ), ( 611, 329, 186 ), ( 611, 376, 155 ), ( 611, 423, 124 ), ( 611, 470, 93 ), ( 611, 517, 62 ), ( 611, 564, 31 ),

( 658, 0, 434 ), ( 658, 47, 403 ), ( 658, 94, 372 ), ( 658, 141, 341 ), ( 658, 188, 310 ), ( 658, 235, 279 ), ( 658, 282, 248 ), ( 658, 329, 217 ), ( 658, 376, 186 ), ( 658, 423, 155 ), ( 658, 470, 124 ), ( 658, 517, 93 ), ( 658, 564, 62 ), ( 658, 611, 31 ),

...

}

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)