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

( 42, 0, 29 ),

( 84, 0, 58 ), ( 84, 42, 29 ),

( 126, 0, 87 ), ( 126, 42, 58 ), ( 126, 84, 29 ),

( 168, 0, 116 ), ( 168, 42, 87 ), ( 168, 84, 58 ), ( 168, 126, 29 ),

( 210, 0, 145 ), ( 210, 42, 116 ), ( 210, 84, 87 ), ( 210, 126, 58 ), ( 210, 168, 29 ),

( 252, 0, 174 ), ( 252, 42, 145 ), ( 252, 84, 116 ), ( 252, 126, 87 ), ( 252, 168, 58 ), ( 252, 210, 29 ),

( 294, 0, 203 ), ( 294, 42, 174 ), ( 294, 84, 145 ), ( 294, 126, 116 ), ( 294, 168, 87 ), ( 294, 210, 58 ), ( 294, 252, 29 ),

( 336, 0, 232 ), ( 336, 42, 203 ), ( 336, 84, 174 ), ( 336, 126, 145 ), ( 336, 168, 116 ), ( 336, 210, 87 ), ( 336, 252, 58 ), ( 336, 294, 29 ),

( 378, 0, 261 ), ( 378, 42, 232 ), ( 378, 84, 203 ), ( 378, 126, 174 ), ( 378, 168, 145 ), ( 378, 210, 116 ), ( 378, 252, 87 ), ( 378, 294, 58 ), ( 378, 336, 29 ),

( 420, 0, 290 ), ( 420, 42, 261 ), ( 420, 84, 232 ), ( 420, 126, 203 ), ( 420, 168, 174 ), ( 420, 210, 145 ), ( 420, 252, 116 ), ( 420, 294, 87 ), ( 420, 336, 58 ), ( 420, 378, 29 ),

( 462, 0, 319 ), ( 462, 42, 290 ), ( 462, 84, 261 ), ( 462, 126, 232 ), ( 462, 168, 203 ), ( 462, 210, 174 ), ( 462, 252, 145 ), ( 462, 294, 116 ), ( 462, 336, 87 ), ( 462, 378, 58 ), ( 462, 420, 29 ),

( 504, 0, 348 ), ( 504, 42, 319 ), ( 504, 84, 290 ), ( 504, 126, 261 ), ( 504, 168, 232 ), ( 504, 210, 203 ), ( 504, 252, 174 ), ( 504, 294, 145 ), ( 504, 336, 116 ), ( 504, 378, 87 ), ( 504, 420, 58 ), ( 504, 462, 29 ),

( 546, 0, 377 ), ( 546, 42, 348 ), ( 546, 84, 319 ), ( 546, 126, 290 ), ( 546, 168, 261 ), ( 546, 210, 232 ), ( 546, 252, 203 ), ( 546, 294, 174 ), ( 546, 336, 145 ), ( 546, 378, 116 ), ( 546, 420, 87 ), ( 546, 462, 58 ), ( 546, 504, 29 ),

( 588, 0, 406 ), ( 588, 42, 377 ), ( 588, 84, 348 ), ( 588, 126, 319 ), ( 588, 168, 290 ), ( 588, 210, 261 ), ( 588, 252, 232 ), ( 588, 294, 203 ), ( 588, 336, 174 ), ( 588, 378, 145 ), ( 588, 420, 116 ), ( 588, 462, 87 ), ( 588, 504, 58 ), ( 588, 546, 29 ),

...

}

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)