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

( 21, 0, 4 ),

( 42, 0, 8 ), ( 42, 21, 4 ),

( 63, 0, 12 ), ( 63, 21, 8 ), ( 63, 42, 4 ),

( 84, 0, 16 ), ( 84, 21, 12 ), ( 84, 42, 8 ), ( 84, 63, 4 ),

( 105, 0, 20 ), ( 105, 21, 16 ), ( 105, 42, 12 ), ( 105, 63, 8 ), ( 105, 84, 4 ),

( 126, 0, 24 ), ( 126, 21, 20 ), ( 126, 42, 16 ), ( 126, 63, 12 ), ( 126, 84, 8 ), ( 126, 105, 4 ),

( 147, 0, 28 ), ( 147, 21, 24 ), ( 147, 42, 20 ), ( 147, 63, 16 ), ( 147, 84, 12 ), ( 147, 105, 8 ), ( 147, 126, 4 ),

( 168, 0, 32 ), ( 168, 21, 28 ), ( 168, 42, 24 ), ( 168, 63, 20 ), ( 168, 84, 16 ), ( 168, 105, 12 ), ( 168, 126, 8 ), ( 168, 147, 4 ),

( 189, 0, 36 ), ( 189, 21, 32 ), ( 189, 42, 28 ), ( 189, 63, 24 ), ( 189, 84, 20 ), ( 189, 105, 16 ), ( 189, 126, 12 ), ( 189, 147, 8 ), ( 189, 168, 4 ),

( 210, 0, 40 ), ( 210, 21, 36 ), ( 210, 42, 32 ), ( 210, 63, 28 ), ( 210, 84, 24 ), ( 210, 105, 20 ), ( 210, 126, 16 ), ( 210, 147, 12 ), ( 210, 168, 8 ), ( 210, 189, 4 ),

( 231, 0, 44 ), ( 231, 21, 40 ), ( 231, 42, 36 ), ( 231, 63, 32 ), ( 231, 84, 28 ), ( 231, 105, 24 ), ( 231, 126, 20 ), ( 231, 147, 16 ), ( 231, 168, 12 ), ( 231, 189, 8 ), ( 231, 210, 4 ),

( 252, 0, 48 ), ( 252, 21, 44 ), ( 252, 42, 40 ), ( 252, 63, 36 ), ( 252, 84, 32 ), ( 252, 105, 28 ), ( 252, 126, 24 ), ( 252, 147, 20 ), ( 252, 168, 16 ), ( 252, 189, 12 ), ( 252, 210, 8 ), ( 252, 231, 4 ),

( 273, 0, 52 ), ( 273, 21, 48 ), ( 273, 42, 44 ), ( 273, 63, 40 ), ( 273, 84, 36 ), ( 273, 105, 32 ), ( 273, 126, 28 ), ( 273, 147, 24 ), ( 273, 168, 20 ), ( 273, 189, 16 ), ( 273, 210, 12 ), ( 273, 231, 8 ), ( 273, 252, 4 ),

( 294, 0, 56 ), ( 294, 21, 52 ), ( 294, 42, 48 ), ( 294, 63, 44 ), ( 294, 84, 40 ), ( 294, 105, 36 ), ( 294, 126, 32 ), ( 294, 147, 28 ), ( 294, 168, 24 ), ( 294, 189, 20 ), ( 294, 210, 16 ), ( 294, 231, 12 ), ( 294, 252, 8 ), ( 294, 273, 4 ),

...

}

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)