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

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

( 22, 0, 9 ),

( 44, 0, 18 ), ( 44, 22, 9 ),

( 66, 0, 27 ), ( 66, 22, 18 ), ( 66, 44, 9 ),

( 88, 0, 36 ), ( 88, 22, 27 ), ( 88, 44, 18 ), ( 88, 66, 9 ),

( 110, 0, 45 ), ( 110, 22, 36 ), ( 110, 44, 27 ), ( 110, 66, 18 ), ( 110, 88, 9 ),

( 132, 0, 54 ), ( 132, 22, 45 ), ( 132, 44, 36 ), ( 132, 66, 27 ), ( 132, 88, 18 ), ( 132, 110, 9 ),

( 154, 0, 63 ), ( 154, 22, 54 ), ( 154, 44, 45 ), ( 154, 66, 36 ), ( 154, 88, 27 ), ( 154, 110, 18 ), ( 154, 132, 9 ),

( 176, 0, 72 ), ( 176, 22, 63 ), ( 176, 44, 54 ), ( 176, 66, 45 ), ( 176, 88, 36 ), ( 176, 110, 27 ), ( 176, 132, 18 ), ( 176, 154, 9 ),

( 198, 0, 81 ), ( 198, 22, 72 ), ( 198, 44, 63 ), ( 198, 66, 54 ), ( 198, 88, 45 ), ( 198, 110, 36 ), ( 198, 132, 27 ), ( 198, 154, 18 ), ( 198, 176, 9 ),

( 220, 0, 90 ), ( 220, 22, 81 ), ( 220, 44, 72 ), ( 220, 66, 63 ), ( 220, 88, 54 ), ( 220, 110, 45 ), ( 220, 132, 36 ), ( 220, 154, 27 ), ( 220, 176, 18 ), ( 220, 198, 9 ),

( 242, 0, 99 ), ( 242, 22, 90 ), ( 242, 44, 81 ), ( 242, 66, 72 ), ( 242, 88, 63 ), ( 242, 110, 54 ), ( 242, 132, 45 ), ( 242, 154, 36 ), ( 242, 176, 27 ), ( 242, 198, 18 ), ( 242, 220, 9 ),

( 264, 0, 108 ), ( 264, 22, 99 ), ( 264, 44, 90 ), ( 264, 66, 81 ), ( 264, 88, 72 ), ( 264, 110, 63 ), ( 264, 132, 54 ), ( 264, 154, 45 ), ( 264, 176, 36 ), ( 264, 198, 27 ), ( 264, 220, 18 ), ( 264, 242, 9 ),

( 286, 0, 117 ), ( 286, 22, 108 ), ( 286, 44, 99 ), ( 286, 66, 90 ), ( 286, 88, 81 ), ( 286, 110, 72 ), ( 286, 132, 63 ), ( 286, 154, 54 ), ( 286, 176, 45 ), ( 286, 198, 36 ), ( 286, 220, 27 ), ( 286, 242, 18 ), ( 286, 264, 9 ),

( 308, 0, 126 ), ( 308, 22, 117 ), ( 308, 44, 108 ), ( 308, 66, 99 ), ( 308, 88, 90 ), ( 308, 110, 81 ), ( 308, 132, 72 ), ( 308, 154, 63 ), ( 308, 176, 54 ), ( 308, 198, 45 ), ( 308, 220, 36 ), ( 308, 242, 27 ), ( 308, 264, 18 ), ( 308, 286, 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)