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

12/7 = (12-0)/7 = {

( 12, 0, 7 ),

( 24, 0, 14 ), ( 24, 12, 7 ),

( 36, 0, 21 ), ( 36, 12, 14 ), ( 36, 24, 7 ),

( 48, 0, 28 ), ( 48, 12, 21 ), ( 48, 24, 14 ), ( 48, 36, 7 ),

( 60, 0, 35 ), ( 60, 12, 28 ), ( 60, 24, 21 ), ( 60, 36, 14 ), ( 60, 48, 7 ),

( 72, 0, 42 ), ( 72, 12, 35 ), ( 72, 24, 28 ), ( 72, 36, 21 ), ( 72, 48, 14 ), ( 72, 60, 7 ),

( 84, 0, 49 ), ( 84, 12, 42 ), ( 84, 24, 35 ), ( 84, 36, 28 ), ( 84, 48, 21 ), ( 84, 60, 14 ), ( 84, 72, 7 ),

( 96, 0, 56 ), ( 96, 12, 49 ), ( 96, 24, 42 ), ( 96, 36, 35 ), ( 96, 48, 28 ), ( 96, 60, 21 ), ( 96, 72, 14 ), ( 96, 84, 7 ),

( 108, 0, 63 ), ( 108, 12, 56 ), ( 108, 24, 49 ), ( 108, 36, 42 ), ( 108, 48, 35 ), ( 108, 60, 28 ), ( 108, 72, 21 ), ( 108, 84, 14 ), ( 108, 96, 7 ),

( 120, 0, 70 ), ( 120, 12, 63 ), ( 120, 24, 56 ), ( 120, 36, 49 ), ( 120, 48, 42 ), ( 120, 60, 35 ), ( 120, 72, 28 ), ( 120, 84, 21 ), ( 120, 96, 14 ), ( 120, 108, 7 ),

( 132, 0, 77 ), ( 132, 12, 70 ), ( 132, 24, 63 ), ( 132, 36, 56 ), ( 132, 48, 49 ), ( 132, 60, 42 ), ( 132, 72, 35 ), ( 132, 84, 28 ), ( 132, 96, 21 ), ( 132, 108, 14 ), ( 132, 120, 7 ),

( 144, 0, 84 ), ( 144, 12, 77 ), ( 144, 24, 70 ), ( 144, 36, 63 ), ( 144, 48, 56 ), ( 144, 60, 49 ), ( 144, 72, 42 ), ( 144, 84, 35 ), ( 144, 96, 28 ), ( 144, 108, 21 ), ( 144, 120, 14 ), ( 144, 132, 7 ),

( 156, 0, 91 ), ( 156, 12, 84 ), ( 156, 24, 77 ), ( 156, 36, 70 ), ( 156, 48, 63 ), ( 156, 60, 56 ), ( 156, 72, 49 ), ( 156, 84, 42 ), ( 156, 96, 35 ), ( 156, 108, 28 ), ( 156, 120, 21 ), ( 156, 132, 14 ), ( 156, 144, 7 ),

( 168, 0, 98 ), ( 168, 12, 91 ), ( 168, 24, 84 ), ( 168, 36, 77 ), ( 168, 48, 70 ), ( 168, 60, 63 ), ( 168, 72, 56 ), ( 168, 84, 49 ), ( 168, 96, 42 ), ( 168, 108, 35 ), ( 168, 120, 28 ), ( 168, 132, 21 ), ( 168, 144, 14 ), ( 168, 156, 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)