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

21/2 = (21-0)/2 = {

( 21, 0, 2 ),

( 42, 0, 4 ), ( 42, 21, 2 ),

( 63, 0, 6 ), ( 63, 21, 4 ), ( 63, 42, 2 ),

( 84, 0, 8 ), ( 84, 21, 6 ), ( 84, 42, 4 ), ( 84, 63, 2 ),

( 105, 0, 10 ), ( 105, 21, 8 ), ( 105, 42, 6 ), ( 105, 63, 4 ), ( 105, 84, 2 ),

( 126, 0, 12 ), ( 126, 21, 10 ), ( 126, 42, 8 ), ( 126, 63, 6 ), ( 126, 84, 4 ), ( 126, 105, 2 ),

( 147, 0, 14 ), ( 147, 21, 12 ), ( 147, 42, 10 ), ( 147, 63, 8 ), ( 147, 84, 6 ), ( 147, 105, 4 ), ( 147, 126, 2 ),

( 168, 0, 16 ), ( 168, 21, 14 ), ( 168, 42, 12 ), ( 168, 63, 10 ), ( 168, 84, 8 ), ( 168, 105, 6 ), ( 168, 126, 4 ), ( 168, 147, 2 ),

( 189, 0, 18 ), ( 189, 21, 16 ), ( 189, 42, 14 ), ( 189, 63, 12 ), ( 189, 84, 10 ), ( 189, 105, 8 ), ( 189, 126, 6 ), ( 189, 147, 4 ), ( 189, 168, 2 ),

( 210, 0, 20 ), ( 210, 21, 18 ), ( 210, 42, 16 ), ( 210, 63, 14 ), ( 210, 84, 12 ), ( 210, 105, 10 ), ( 210, 126, 8 ), ( 210, 147, 6 ), ( 210, 168, 4 ), ( 210, 189, 2 ),

( 231, 0, 22 ), ( 231, 21, 20 ), ( 231, 42, 18 ), ( 231, 63, 16 ), ( 231, 84, 14 ), ( 231, 105, 12 ), ( 231, 126, 10 ), ( 231, 147, 8 ), ( 231, 168, 6 ), ( 231, 189, 4 ), ( 231, 210, 2 ),

( 252, 0, 24 ), ( 252, 21, 22 ), ( 252, 42, 20 ), ( 252, 63, 18 ), ( 252, 84, 16 ), ( 252, 105, 14 ), ( 252, 126, 12 ), ( 252, 147, 10 ), ( 252, 168, 8 ), ( 252, 189, 6 ), ( 252, 210, 4 ), ( 252, 231, 2 ),

( 273, 0, 26 ), ( 273, 21, 24 ), ( 273, 42, 22 ), ( 273, 63, 20 ), ( 273, 84, 18 ), ( 273, 105, 16 ), ( 273, 126, 14 ), ( 273, 147, 12 ), ( 273, 168, 10 ), ( 273, 189, 8 ), ( 273, 210, 6 ), ( 273, 231, 4 ), ( 273, 252, 2 ),

( 294, 0, 28 ), ( 294, 21, 26 ), ( 294, 42, 24 ), ( 294, 63, 22 ), ( 294, 84, 20 ), ( 294, 105, 18 ), ( 294, 126, 16 ), ( 294, 147, 14 ), ( 294, 168, 12 ), ( 294, 189, 10 ), ( 294, 210, 8 ), ( 294, 231, 6 ), ( 294, 252, 4 ), ( 294, 273, 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)