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

17/6 = (17-0)/6 = {

( 17, 0, 6 ),

( 34, 0, 12 ), ( 34, 17, 6 ),

( 51, 0, 18 ), ( 51, 17, 12 ), ( 51, 34, 6 ),

( 68, 0, 24 ), ( 68, 17, 18 ), ( 68, 34, 12 ), ( 68, 51, 6 ),

( 85, 0, 30 ), ( 85, 17, 24 ), ( 85, 34, 18 ), ( 85, 51, 12 ), ( 85, 68, 6 ),

( 102, 0, 36 ), ( 102, 17, 30 ), ( 102, 34, 24 ), ( 102, 51, 18 ), ( 102, 68, 12 ), ( 102, 85, 6 ),

( 119, 0, 42 ), ( 119, 17, 36 ), ( 119, 34, 30 ), ( 119, 51, 24 ), ( 119, 68, 18 ), ( 119, 85, 12 ), ( 119, 102, 6 ),

( 136, 0, 48 ), ( 136, 17, 42 ), ( 136, 34, 36 ), ( 136, 51, 30 ), ( 136, 68, 24 ), ( 136, 85, 18 ), ( 136, 102, 12 ), ( 136, 119, 6 ),

( 153, 0, 54 ), ( 153, 17, 48 ), ( 153, 34, 42 ), ( 153, 51, 36 ), ( 153, 68, 30 ), ( 153, 85, 24 ), ( 153, 102, 18 ), ( 153, 119, 12 ), ( 153, 136, 6 ),

( 170, 0, 60 ), ( 170, 17, 54 ), ( 170, 34, 48 ), ( 170, 51, 42 ), ( 170, 68, 36 ), ( 170, 85, 30 ), ( 170, 102, 24 ), ( 170, 119, 18 ), ( 170, 136, 12 ), ( 170, 153, 6 ),

( 187, 0, 66 ), ( 187, 17, 60 ), ( 187, 34, 54 ), ( 187, 51, 48 ), ( 187, 68, 42 ), ( 187, 85, 36 ), ( 187, 102, 30 ), ( 187, 119, 24 ), ( 187, 136, 18 ), ( 187, 153, 12 ), ( 187, 170, 6 ),

( 204, 0, 72 ), ( 204, 17, 66 ), ( 204, 34, 60 ), ( 204, 51, 54 ), ( 204, 68, 48 ), ( 204, 85, 42 ), ( 204, 102, 36 ), ( 204, 119, 30 ), ( 204, 136, 24 ), ( 204, 153, 18 ), ( 204, 170, 12 ), ( 204, 187, 6 ),

( 221, 0, 78 ), ( 221, 17, 72 ), ( 221, 34, 66 ), ( 221, 51, 60 ), ( 221, 68, 54 ), ( 221, 85, 48 ), ( 221, 102, 42 ), ( 221, 119, 36 ), ( 221, 136, 30 ), ( 221, 153, 24 ), ( 221, 170, 18 ), ( 221, 187, 12 ), ( 221, 204, 6 ),

( 238, 0, 84 ), ( 238, 17, 78 ), ( 238, 34, 72 ), ( 238, 51, 66 ), ( 238, 68, 60 ), ( 238, 85, 54 ), ( 238, 102, 48 ), ( 238, 119, 42 ), ( 238, 136, 36 ), ( 238, 153, 30 ), ( 238, 170, 24 ), ( 238, 187, 18 ), ( 238, 204, 12 ), ( 238, 221, 6 ),

...

}

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)