The rational number 39/8 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.

39/8 = (39-0)/8 = {

( 39, 0, 8 ),

( 78, 0, 16 ), ( 78, 39, 8 ),

( 117, 0, 24 ), ( 117, 39, 16 ), ( 117, 78, 8 ),

( 156, 0, 32 ), ( 156, 39, 24 ), ( 156, 78, 16 ), ( 156, 117, 8 ),

( 195, 0, 40 ), ( 195, 39, 32 ), ( 195, 78, 24 ), ( 195, 117, 16 ), ( 195, 156, 8 ),

( 234, 0, 48 ), ( 234, 39, 40 ), ( 234, 78, 32 ), ( 234, 117, 24 ), ( 234, 156, 16 ), ( 234, 195, 8 ),

( 273, 0, 56 ), ( 273, 39, 48 ), ( 273, 78, 40 ), ( 273, 117, 32 ), ( 273, 156, 24 ), ( 273, 195, 16 ), ( 273, 234, 8 ),

( 312, 0, 64 ), ( 312, 39, 56 ), ( 312, 78, 48 ), ( 312, 117, 40 ), ( 312, 156, 32 ), ( 312, 195, 24 ), ( 312, 234, 16 ), ( 312, 273, 8 ),

( 351, 0, 72 ), ( 351, 39, 64 ), ( 351, 78, 56 ), ( 351, 117, 48 ), ( 351, 156, 40 ), ( 351, 195, 32 ), ( 351, 234, 24 ), ( 351, 273, 16 ), ( 351, 312, 8 ),

( 390, 0, 80 ), ( 390, 39, 72 ), ( 390, 78, 64 ), ( 390, 117, 56 ), ( 390, 156, 48 ), ( 390, 195, 40 ), ( 390, 234, 32 ), ( 390, 273, 24 ), ( 390, 312, 16 ), ( 390, 351, 8 ),

( 429, 0, 88 ), ( 429, 39, 80 ), ( 429, 78, 72 ), ( 429, 117, 64 ), ( 429, 156, 56 ), ( 429, 195, 48 ), ( 429, 234, 40 ), ( 429, 273, 32 ), ( 429, 312, 24 ), ( 429, 351, 16 ), ( 429, 390, 8 ),

( 468, 0, 96 ), ( 468, 39, 88 ), ( 468, 78, 80 ), ( 468, 117, 72 ), ( 468, 156, 64 ), ( 468, 195, 56 ), ( 468, 234, 48 ), ( 468, 273, 40 ), ( 468, 312, 32 ), ( 468, 351, 24 ), ( 468, 390, 16 ), ( 468, 429, 8 ),

( 507, 0, 104 ), ( 507, 39, 96 ), ( 507, 78, 88 ), ( 507, 117, 80 ), ( 507, 156, 72 ), ( 507, 195, 64 ), ( 507, 234, 56 ), ( 507, 273, 48 ), ( 507, 312, 40 ), ( 507, 351, 32 ), ( 507, 390, 24 ), ( 507, 429, 16 ), ( 507, 468, 8 ),

( 546, 0, 112 ), ( 546, 39, 104 ), ( 546, 78, 96 ), ( 546, 117, 88 ), ( 546, 156, 80 ), ( 546, 195, 72 ), ( 546, 234, 64 ), ( 546, 273, 56 ), ( 546, 312, 48 ), ( 546, 351, 40 ), ( 546, 390, 32 ), ( 546, 429, 24 ), ( 546, 468, 16 ), ( 546, 507, 8 ),

...

}

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)