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

( 7, 0, 2 ),

( 14, 0, 4 ), ( 14, 7, 2 ),

( 21, 0, 6 ), ( 21, 7, 4 ), ( 21, 14, 2 ),

( 28, 0, 8 ), ( 28, 7, 6 ), ( 28, 14, 4 ), ( 28, 21, 2 ),

( 35, 0, 10 ), ( 35, 7, 8 ), ( 35, 14, 6 ), ( 35, 21, 4 ), ( 35, 28, 2 ),

( 42, 0, 12 ), ( 42, 7, 10 ), ( 42, 14, 8 ), ( 42, 21, 6 ), ( 42, 28, 4 ), ( 42, 35, 2 ),

( 49, 0, 14 ), ( 49, 7, 12 ), ( 49, 14, 10 ), ( 49, 21, 8 ), ( 49, 28, 6 ), ( 49, 35, 4 ), ( 49, 42, 2 ),

( 56, 0, 16 ), ( 56, 7, 14 ), ( 56, 14, 12 ), ( 56, 21, 10 ), ( 56, 28, 8 ), ( 56, 35, 6 ), ( 56, 42, 4 ), ( 56, 49, 2 ),

( 63, 0, 18 ), ( 63, 7, 16 ), ( 63, 14, 14 ), ( 63, 21, 12 ), ( 63, 28, 10 ), ( 63, 35, 8 ), ( 63, 42, 6 ), ( 63, 49, 4 ), ( 63, 56, 2 ),

( 70, 0, 20 ), ( 70, 7, 18 ), ( 70, 14, 16 ), ( 70, 21, 14 ), ( 70, 28, 12 ), ( 70, 35, 10 ), ( 70, 42, 8 ), ( 70, 49, 6 ), ( 70, 56, 4 ), ( 70, 63, 2 ),

( 77, 0, 22 ), ( 77, 7, 20 ), ( 77, 14, 18 ), ( 77, 21, 16 ), ( 77, 28, 14 ), ( 77, 35, 12 ), ( 77, 42, 10 ), ( 77, 49, 8 ), ( 77, 56, 6 ), ( 77, 63, 4 ), ( 77, 70, 2 ),

( 84, 0, 24 ), ( 84, 7, 22 ), ( 84, 14, 20 ), ( 84, 21, 18 ), ( 84, 28, 16 ), ( 84, 35, 14 ), ( 84, 42, 12 ), ( 84, 49, 10 ), ( 84, 56, 8 ), ( 84, 63, 6 ), ( 84, 70, 4 ), ( 84, 77, 2 ),

( 91, 0, 26 ), ( 91, 7, 24 ), ( 91, 14, 22 ), ( 91, 21, 20 ), ( 91, 28, 18 ), ( 91, 35, 16 ), ( 91, 42, 14 ), ( 91, 49, 12 ), ( 91, 56, 10 ), ( 91, 63, 8 ), ( 91, 70, 6 ), ( 91, 77, 4 ), ( 91, 84, 2 ),

( 98, 0, 28 ), ( 98, 7, 26 ), ( 98, 14, 24 ), ( 98, 21, 22 ), ( 98, 28, 20 ), ( 98, 35, 18 ), ( 98, 42, 16 ), ( 98, 49, 14 ), ( 98, 56, 12 ), ( 98, 63, 10 ), ( 98, 70, 8 ), ( 98, 77, 6 ), ( 98, 84, 4 ), ( 98, 91, 2 ),

...

}

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)