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

26/9 = (26-0)/9 = {

( 26, 0, 9 ),

( 52, 0, 18 ), ( 52, 26, 9 ),

( 78, 0, 27 ), ( 78, 26, 18 ), ( 78, 52, 9 ),

( 104, 0, 36 ), ( 104, 26, 27 ), ( 104, 52, 18 ), ( 104, 78, 9 ),

( 130, 0, 45 ), ( 130, 26, 36 ), ( 130, 52, 27 ), ( 130, 78, 18 ), ( 130, 104, 9 ),

( 156, 0, 54 ), ( 156, 26, 45 ), ( 156, 52, 36 ), ( 156, 78, 27 ), ( 156, 104, 18 ), ( 156, 130, 9 ),

( 182, 0, 63 ), ( 182, 26, 54 ), ( 182, 52, 45 ), ( 182, 78, 36 ), ( 182, 104, 27 ), ( 182, 130, 18 ), ( 182, 156, 9 ),

( 208, 0, 72 ), ( 208, 26, 63 ), ( 208, 52, 54 ), ( 208, 78, 45 ), ( 208, 104, 36 ), ( 208, 130, 27 ), ( 208, 156, 18 ), ( 208, 182, 9 ),

( 234, 0, 81 ), ( 234, 26, 72 ), ( 234, 52, 63 ), ( 234, 78, 54 ), ( 234, 104, 45 ), ( 234, 130, 36 ), ( 234, 156, 27 ), ( 234, 182, 18 ), ( 234, 208, 9 ),

( 260, 0, 90 ), ( 260, 26, 81 ), ( 260, 52, 72 ), ( 260, 78, 63 ), ( 260, 104, 54 ), ( 260, 130, 45 ), ( 260, 156, 36 ), ( 260, 182, 27 ), ( 260, 208, 18 ), ( 260, 234, 9 ),

( 286, 0, 99 ), ( 286, 26, 90 ), ( 286, 52, 81 ), ( 286, 78, 72 ), ( 286, 104, 63 ), ( 286, 130, 54 ), ( 286, 156, 45 ), ( 286, 182, 36 ), ( 286, 208, 27 ), ( 286, 234, 18 ), ( 286, 260, 9 ),

( 312, 0, 108 ), ( 312, 26, 99 ), ( 312, 52, 90 ), ( 312, 78, 81 ), ( 312, 104, 72 ), ( 312, 130, 63 ), ( 312, 156, 54 ), ( 312, 182, 45 ), ( 312, 208, 36 ), ( 312, 234, 27 ), ( 312, 260, 18 ), ( 312, 286, 9 ),

( 338, 0, 117 ), ( 338, 26, 108 ), ( 338, 52, 99 ), ( 338, 78, 90 ), ( 338, 104, 81 ), ( 338, 130, 72 ), ( 338, 156, 63 ), ( 338, 182, 54 ), ( 338, 208, 45 ), ( 338, 234, 36 ), ( 338, 260, 27 ), ( 338, 286, 18 ), ( 338, 312, 9 ),

( 364, 0, 126 ), ( 364, 26, 117 ), ( 364, 52, 108 ), ( 364, 78, 99 ), ( 364, 104, 90 ), ( 364, 130, 81 ), ( 364, 156, 72 ), ( 364, 182, 63 ), ( 364, 208, 54 ), ( 364, 234, 45 ), ( 364, 260, 36 ), ( 364, 286, 27 ), ( 364, 312, 18 ), ( 364, 338, 9 ),

...

}

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)