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

( 21, 0, 13 ),

( 42, 0, 26 ), ( 42, 21, 13 ),

( 63, 0, 39 ), ( 63, 21, 26 ), ( 63, 42, 13 ),

( 84, 0, 52 ), ( 84, 21, 39 ), ( 84, 42, 26 ), ( 84, 63, 13 ),

( 105, 0, 65 ), ( 105, 21, 52 ), ( 105, 42, 39 ), ( 105, 63, 26 ), ( 105, 84, 13 ),

( 126, 0, 78 ), ( 126, 21, 65 ), ( 126, 42, 52 ), ( 126, 63, 39 ), ( 126, 84, 26 ), ( 126, 105, 13 ),

( 147, 0, 91 ), ( 147, 21, 78 ), ( 147, 42, 65 ), ( 147, 63, 52 ), ( 147, 84, 39 ), ( 147, 105, 26 ), ( 147, 126, 13 ),

( 168, 0, 104 ), ( 168, 21, 91 ), ( 168, 42, 78 ), ( 168, 63, 65 ), ( 168, 84, 52 ), ( 168, 105, 39 ), ( 168, 126, 26 ), ( 168, 147, 13 ),

( 189, 0, 117 ), ( 189, 21, 104 ), ( 189, 42, 91 ), ( 189, 63, 78 ), ( 189, 84, 65 ), ( 189, 105, 52 ), ( 189, 126, 39 ), ( 189, 147, 26 ), ( 189, 168, 13 ),

( 210, 0, 130 ), ( 210, 21, 117 ), ( 210, 42, 104 ), ( 210, 63, 91 ), ( 210, 84, 78 ), ( 210, 105, 65 ), ( 210, 126, 52 ), ( 210, 147, 39 ), ( 210, 168, 26 ), ( 210, 189, 13 ),

( 231, 0, 143 ), ( 231, 21, 130 ), ( 231, 42, 117 ), ( 231, 63, 104 ), ( 231, 84, 91 ), ( 231, 105, 78 ), ( 231, 126, 65 ), ( 231, 147, 52 ), ( 231, 168, 39 ), ( 231, 189, 26 ), ( 231, 210, 13 ),

( 252, 0, 156 ), ( 252, 21, 143 ), ( 252, 42, 130 ), ( 252, 63, 117 ), ( 252, 84, 104 ), ( 252, 105, 91 ), ( 252, 126, 78 ), ( 252, 147, 65 ), ( 252, 168, 52 ), ( 252, 189, 39 ), ( 252, 210, 26 ), ( 252, 231, 13 ),

( 273, 0, 169 ), ( 273, 21, 156 ), ( 273, 42, 143 ), ( 273, 63, 130 ), ( 273, 84, 117 ), ( 273, 105, 104 ), ( 273, 126, 91 ), ( 273, 147, 78 ), ( 273, 168, 65 ), ( 273, 189, 52 ), ( 273, 210, 39 ), ( 273, 231, 26 ), ( 273, 252, 13 ),

( 294, 0, 182 ), ( 294, 21, 169 ), ( 294, 42, 156 ), ( 294, 63, 143 ), ( 294, 84, 130 ), ( 294, 105, 117 ), ( 294, 126, 104 ), ( 294, 147, 91 ), ( 294, 168, 78 ), ( 294, 189, 65 ), ( 294, 210, 52 ), ( 294, 231, 39 ), ( 294, 252, 26 ), ( 294, 273, 13 ),

...

}

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)