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

( 39, 0, 7 ),

( 78, 0, 14 ), ( 78, 39, 7 ),

( 117, 0, 21 ), ( 117, 39, 14 ), ( 117, 78, 7 ),

( 156, 0, 28 ), ( 156, 39, 21 ), ( 156, 78, 14 ), ( 156, 117, 7 ),

( 195, 0, 35 ), ( 195, 39, 28 ), ( 195, 78, 21 ), ( 195, 117, 14 ), ( 195, 156, 7 ),

( 234, 0, 42 ), ( 234, 39, 35 ), ( 234, 78, 28 ), ( 234, 117, 21 ), ( 234, 156, 14 ), ( 234, 195, 7 ),

( 273, 0, 49 ), ( 273, 39, 42 ), ( 273, 78, 35 ), ( 273, 117, 28 ), ( 273, 156, 21 ), ( 273, 195, 14 ), ( 273, 234, 7 ),

( 312, 0, 56 ), ( 312, 39, 49 ), ( 312, 78, 42 ), ( 312, 117, 35 ), ( 312, 156, 28 ), ( 312, 195, 21 ), ( 312, 234, 14 ), ( 312, 273, 7 ),

( 351, 0, 63 ), ( 351, 39, 56 ), ( 351, 78, 49 ), ( 351, 117, 42 ), ( 351, 156, 35 ), ( 351, 195, 28 ), ( 351, 234, 21 ), ( 351, 273, 14 ), ( 351, 312, 7 ),

( 390, 0, 70 ), ( 390, 39, 63 ), ( 390, 78, 56 ), ( 390, 117, 49 ), ( 390, 156, 42 ), ( 390, 195, 35 ), ( 390, 234, 28 ), ( 390, 273, 21 ), ( 390, 312, 14 ), ( 390, 351, 7 ),

( 429, 0, 77 ), ( 429, 39, 70 ), ( 429, 78, 63 ), ( 429, 117, 56 ), ( 429, 156, 49 ), ( 429, 195, 42 ), ( 429, 234, 35 ), ( 429, 273, 28 ), ( 429, 312, 21 ), ( 429, 351, 14 ), ( 429, 390, 7 ),

( 468, 0, 84 ), ( 468, 39, 77 ), ( 468, 78, 70 ), ( 468, 117, 63 ), ( 468, 156, 56 ), ( 468, 195, 49 ), ( 468, 234, 42 ), ( 468, 273, 35 ), ( 468, 312, 28 ), ( 468, 351, 21 ), ( 468, 390, 14 ), ( 468, 429, 7 ),

( 507, 0, 91 ), ( 507, 39, 84 ), ( 507, 78, 77 ), ( 507, 117, 70 ), ( 507, 156, 63 ), ( 507, 195, 56 ), ( 507, 234, 49 ), ( 507, 273, 42 ), ( 507, 312, 35 ), ( 507, 351, 28 ), ( 507, 390, 21 ), ( 507, 429, 14 ), ( 507, 468, 7 ),

( 546, 0, 98 ), ( 546, 39, 91 ), ( 546, 78, 84 ), ( 546, 117, 77 ), ( 546, 156, 70 ), ( 546, 195, 63 ), ( 546, 234, 56 ), ( 546, 273, 49 ), ( 546, 312, 42 ), ( 546, 351, 35 ), ( 546, 390, 28 ), ( 546, 429, 21 ), ( 546, 468, 14 ), ( 546, 507, 7 ),

...

}

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)