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

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

( 7, 0, 3 ),

( 14, 0, 6 ), ( 14, 7, 3 ),

( 21, 0, 9 ), ( 21, 7, 6 ), ( 21, 14, 3 ),

( 28, 0, 12 ), ( 28, 7, 9 ), ( 28, 14, 6 ), ( 28, 21, 3 ),

( 35, 0, 15 ), ( 35, 7, 12 ), ( 35, 14, 9 ), ( 35, 21, 6 ), ( 35, 28, 3 ),

( 42, 0, 18 ), ( 42, 7, 15 ), ( 42, 14, 12 ), ( 42, 21, 9 ), ( 42, 28, 6 ), ( 42, 35, 3 ),

( 49, 0, 21 ), ( 49, 7, 18 ), ( 49, 14, 15 ), ( 49, 21, 12 ), ( 49, 28, 9 ), ( 49, 35, 6 ), ( 49, 42, 3 ),

( 56, 0, 24 ), ( 56, 7, 21 ), ( 56, 14, 18 ), ( 56, 21, 15 ), ( 56, 28, 12 ), ( 56, 35, 9 ), ( 56, 42, 6 ), ( 56, 49, 3 ),

( 63, 0, 27 ), ( 63, 7, 24 ), ( 63, 14, 21 ), ( 63, 21, 18 ), ( 63, 28, 15 ), ( 63, 35, 12 ), ( 63, 42, 9 ), ( 63, 49, 6 ), ( 63, 56, 3 ),

( 70, 0, 30 ), ( 70, 7, 27 ), ( 70, 14, 24 ), ( 70, 21, 21 ), ( 70, 28, 18 ), ( 70, 35, 15 ), ( 70, 42, 12 ), ( 70, 49, 9 ), ( 70, 56, 6 ), ( 70, 63, 3 ),

( 77, 0, 33 ), ( 77, 7, 30 ), ( 77, 14, 27 ), ( 77, 21, 24 ), ( 77, 28, 21 ), ( 77, 35, 18 ), ( 77, 42, 15 ), ( 77, 49, 12 ), ( 77, 56, 9 ), ( 77, 63, 6 ), ( 77, 70, 3 ),

( 84, 0, 36 ), ( 84, 7, 33 ), ( 84, 14, 30 ), ( 84, 21, 27 ), ( 84, 28, 24 ), ( 84, 35, 21 ), ( 84, 42, 18 ), ( 84, 49, 15 ), ( 84, 56, 12 ), ( 84, 63, 9 ), ( 84, 70, 6 ), ( 84, 77, 3 ),

( 91, 0, 39 ), ( 91, 7, 36 ), ( 91, 14, 33 ), ( 91, 21, 30 ), ( 91, 28, 27 ), ( 91, 35, 24 ), ( 91, 42, 21 ), ( 91, 49, 18 ), ( 91, 56, 15 ), ( 91, 63, 12 ), ( 91, 70, 9 ), ( 91, 77, 6 ), ( 91, 84, 3 ),

( 98, 0, 42 ), ( 98, 7, 39 ), ( 98, 14, 36 ), ( 98, 21, 33 ), ( 98, 28, 30 ), ( 98, 35, 27 ), ( 98, 42, 24 ), ( 98, 49, 21 ), ( 98, 56, 18 ), ( 98, 63, 15 ), ( 98, 70, 12 ), ( 98, 77, 9 ), ( 98, 84, 6 ), ( 98, 91, 3 ),

...

}

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)