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

42/13 = (42-0)/13 = {

( 42, 0, 13 ),

( 84, 0, 26 ), ( 84, 42, 13 ),

( 126, 0, 39 ), ( 126, 42, 26 ), ( 126, 84, 13 ),

( 168, 0, 52 ), ( 168, 42, 39 ), ( 168, 84, 26 ), ( 168, 126, 13 ),

( 210, 0, 65 ), ( 210, 42, 52 ), ( 210, 84, 39 ), ( 210, 126, 26 ), ( 210, 168, 13 ),

( 252, 0, 78 ), ( 252, 42, 65 ), ( 252, 84, 52 ), ( 252, 126, 39 ), ( 252, 168, 26 ), ( 252, 210, 13 ),

( 294, 0, 91 ), ( 294, 42, 78 ), ( 294, 84, 65 ), ( 294, 126, 52 ), ( 294, 168, 39 ), ( 294, 210, 26 ), ( 294, 252, 13 ),

( 336, 0, 104 ), ( 336, 42, 91 ), ( 336, 84, 78 ), ( 336, 126, 65 ), ( 336, 168, 52 ), ( 336, 210, 39 ), ( 336, 252, 26 ), ( 336, 294, 13 ),

( 378, 0, 117 ), ( 378, 42, 104 ), ( 378, 84, 91 ), ( 378, 126, 78 ), ( 378, 168, 65 ), ( 378, 210, 52 ), ( 378, 252, 39 ), ( 378, 294, 26 ), ( 378, 336, 13 ),

( 420, 0, 130 ), ( 420, 42, 117 ), ( 420, 84, 104 ), ( 420, 126, 91 ), ( 420, 168, 78 ), ( 420, 210, 65 ), ( 420, 252, 52 ), ( 420, 294, 39 ), ( 420, 336, 26 ), ( 420, 378, 13 ),

( 462, 0, 143 ), ( 462, 42, 130 ), ( 462, 84, 117 ), ( 462, 126, 104 ), ( 462, 168, 91 ), ( 462, 210, 78 ), ( 462, 252, 65 ), ( 462, 294, 52 ), ( 462, 336, 39 ), ( 462, 378, 26 ), ( 462, 420, 13 ),

( 504, 0, 156 ), ( 504, 42, 143 ), ( 504, 84, 130 ), ( 504, 126, 117 ), ( 504, 168, 104 ), ( 504, 210, 91 ), ( 504, 252, 78 ), ( 504, 294, 65 ), ( 504, 336, 52 ), ( 504, 378, 39 ), ( 504, 420, 26 ), ( 504, 462, 13 ),

( 546, 0, 169 ), ( 546, 42, 156 ), ( 546, 84, 143 ), ( 546, 126, 130 ), ( 546, 168, 117 ), ( 546, 210, 104 ), ( 546, 252, 91 ), ( 546, 294, 78 ), ( 546, 336, 65 ), ( 546, 378, 52 ), ( 546, 420, 39 ), ( 546, 462, 26 ), ( 546, 504, 13 ),

( 588, 0, 182 ), ( 588, 42, 169 ), ( 588, 84, 156 ), ( 588, 126, 143 ), ( 588, 168, 130 ), ( 588, 210, 117 ), ( 588, 252, 104 ), ( 588, 294, 91 ), ( 588, 336, 78 ), ( 588, 378, 65 ), ( 588, 420, 52 ), ( 588, 462, 39 ), ( 588, 504, 26 ), ( 588, 546, 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)