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

( 22, 0, 7 ),

( 44, 0, 14 ), ( 44, 22, 7 ),

( 66, 0, 21 ), ( 66, 22, 14 ), ( 66, 44, 7 ),

( 88, 0, 28 ), ( 88, 22, 21 ), ( 88, 44, 14 ), ( 88, 66, 7 ),

( 110, 0, 35 ), ( 110, 22, 28 ), ( 110, 44, 21 ), ( 110, 66, 14 ), ( 110, 88, 7 ),

( 132, 0, 42 ), ( 132, 22, 35 ), ( 132, 44, 28 ), ( 132, 66, 21 ), ( 132, 88, 14 ), ( 132, 110, 7 ),

( 154, 0, 49 ), ( 154, 22, 42 ), ( 154, 44, 35 ), ( 154, 66, 28 ), ( 154, 88, 21 ), ( 154, 110, 14 ), ( 154, 132, 7 ),

( 176, 0, 56 ), ( 176, 22, 49 ), ( 176, 44, 42 ), ( 176, 66, 35 ), ( 176, 88, 28 ), ( 176, 110, 21 ), ( 176, 132, 14 ), ( 176, 154, 7 ),

( 198, 0, 63 ), ( 198, 22, 56 ), ( 198, 44, 49 ), ( 198, 66, 42 ), ( 198, 88, 35 ), ( 198, 110, 28 ), ( 198, 132, 21 ), ( 198, 154, 14 ), ( 198, 176, 7 ),

( 220, 0, 70 ), ( 220, 22, 63 ), ( 220, 44, 56 ), ( 220, 66, 49 ), ( 220, 88, 42 ), ( 220, 110, 35 ), ( 220, 132, 28 ), ( 220, 154, 21 ), ( 220, 176, 14 ), ( 220, 198, 7 ),

( 242, 0, 77 ), ( 242, 22, 70 ), ( 242, 44, 63 ), ( 242, 66, 56 ), ( 242, 88, 49 ), ( 242, 110, 42 ), ( 242, 132, 35 ), ( 242, 154, 28 ), ( 242, 176, 21 ), ( 242, 198, 14 ), ( 242, 220, 7 ),

( 264, 0, 84 ), ( 264, 22, 77 ), ( 264, 44, 70 ), ( 264, 66, 63 ), ( 264, 88, 56 ), ( 264, 110, 49 ), ( 264, 132, 42 ), ( 264, 154, 35 ), ( 264, 176, 28 ), ( 264, 198, 21 ), ( 264, 220, 14 ), ( 264, 242, 7 ),

( 286, 0, 91 ), ( 286, 22, 84 ), ( 286, 44, 77 ), ( 286, 66, 70 ), ( 286, 88, 63 ), ( 286, 110, 56 ), ( 286, 132, 49 ), ( 286, 154, 42 ), ( 286, 176, 35 ), ( 286, 198, 28 ), ( 286, 220, 21 ), ( 286, 242, 14 ), ( 286, 264, 7 ),

( 308, 0, 98 ), ( 308, 22, 91 ), ( 308, 44, 84 ), ( 308, 66, 77 ), ( 308, 88, 70 ), ( 308, 110, 63 ), ( 308, 132, 56 ), ( 308, 154, 49 ), ( 308, 176, 42 ), ( 308, 198, 35 ), ( 308, 220, 28 ), ( 308, 242, 21 ), ( 308, 264, 14 ), ( 308, 286, 7 ),

...

}

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)