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

( 17, 0, 5 ),

( 34, 0, 10 ), ( 34, 17, 5 ),

( 51, 0, 15 ), ( 51, 17, 10 ), ( 51, 34, 5 ),

( 68, 0, 20 ), ( 68, 17, 15 ), ( 68, 34, 10 ), ( 68, 51, 5 ),

( 85, 0, 25 ), ( 85, 17, 20 ), ( 85, 34, 15 ), ( 85, 51, 10 ), ( 85, 68, 5 ),

( 102, 0, 30 ), ( 102, 17, 25 ), ( 102, 34, 20 ), ( 102, 51, 15 ), ( 102, 68, 10 ), ( 102, 85, 5 ),

( 119, 0, 35 ), ( 119, 17, 30 ), ( 119, 34, 25 ), ( 119, 51, 20 ), ( 119, 68, 15 ), ( 119, 85, 10 ), ( 119, 102, 5 ),

( 136, 0, 40 ), ( 136, 17, 35 ), ( 136, 34, 30 ), ( 136, 51, 25 ), ( 136, 68, 20 ), ( 136, 85, 15 ), ( 136, 102, 10 ), ( 136, 119, 5 ),

( 153, 0, 45 ), ( 153, 17, 40 ), ( 153, 34, 35 ), ( 153, 51, 30 ), ( 153, 68, 25 ), ( 153, 85, 20 ), ( 153, 102, 15 ), ( 153, 119, 10 ), ( 153, 136, 5 ),

( 170, 0, 50 ), ( 170, 17, 45 ), ( 170, 34, 40 ), ( 170, 51, 35 ), ( 170, 68, 30 ), ( 170, 85, 25 ), ( 170, 102, 20 ), ( 170, 119, 15 ), ( 170, 136, 10 ), ( 170, 153, 5 ),

( 187, 0, 55 ), ( 187, 17, 50 ), ( 187, 34, 45 ), ( 187, 51, 40 ), ( 187, 68, 35 ), ( 187, 85, 30 ), ( 187, 102, 25 ), ( 187, 119, 20 ), ( 187, 136, 15 ), ( 187, 153, 10 ), ( 187, 170, 5 ),

( 204, 0, 60 ), ( 204, 17, 55 ), ( 204, 34, 50 ), ( 204, 51, 45 ), ( 204, 68, 40 ), ( 204, 85, 35 ), ( 204, 102, 30 ), ( 204, 119, 25 ), ( 204, 136, 20 ), ( 204, 153, 15 ), ( 204, 170, 10 ), ( 204, 187, 5 ),

( 221, 0, 65 ), ( 221, 17, 60 ), ( 221, 34, 55 ), ( 221, 51, 50 ), ( 221, 68, 45 ), ( 221, 85, 40 ), ( 221, 102, 35 ), ( 221, 119, 30 ), ( 221, 136, 25 ), ( 221, 153, 20 ), ( 221, 170, 15 ), ( 221, 187, 10 ), ( 221, 204, 5 ),

( 238, 0, 70 ), ( 238, 17, 65 ), ( 238, 34, 60 ), ( 238, 51, 55 ), ( 238, 68, 50 ), ( 238, 85, 45 ), ( 238, 102, 40 ), ( 238, 119, 35 ), ( 238, 136, 30 ), ( 238, 153, 25 ), ( 238, 170, 20 ), ( 238, 187, 15 ), ( 238, 204, 10 ), ( 238, 221, 5 ),

...

}

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)