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

( 17, 0, 12 ),

( 34, 0, 24 ), ( 34, 17, 12 ),

( 51, 0, 36 ), ( 51, 17, 24 ), ( 51, 34, 12 ),

( 68, 0, 48 ), ( 68, 17, 36 ), ( 68, 34, 24 ), ( 68, 51, 12 ),

( 85, 0, 60 ), ( 85, 17, 48 ), ( 85, 34, 36 ), ( 85, 51, 24 ), ( 85, 68, 12 ),

( 102, 0, 72 ), ( 102, 17, 60 ), ( 102, 34, 48 ), ( 102, 51, 36 ), ( 102, 68, 24 ), ( 102, 85, 12 ),

( 119, 0, 84 ), ( 119, 17, 72 ), ( 119, 34, 60 ), ( 119, 51, 48 ), ( 119, 68, 36 ), ( 119, 85, 24 ), ( 119, 102, 12 ),

( 136, 0, 96 ), ( 136, 17, 84 ), ( 136, 34, 72 ), ( 136, 51, 60 ), ( 136, 68, 48 ), ( 136, 85, 36 ), ( 136, 102, 24 ), ( 136, 119, 12 ),

( 153, 0, 108 ), ( 153, 17, 96 ), ( 153, 34, 84 ), ( 153, 51, 72 ), ( 153, 68, 60 ), ( 153, 85, 48 ), ( 153, 102, 36 ), ( 153, 119, 24 ), ( 153, 136, 12 ),

( 170, 0, 120 ), ( 170, 17, 108 ), ( 170, 34, 96 ), ( 170, 51, 84 ), ( 170, 68, 72 ), ( 170, 85, 60 ), ( 170, 102, 48 ), ( 170, 119, 36 ), ( 170, 136, 24 ), ( 170, 153, 12 ),

( 187, 0, 132 ), ( 187, 17, 120 ), ( 187, 34, 108 ), ( 187, 51, 96 ), ( 187, 68, 84 ), ( 187, 85, 72 ), ( 187, 102, 60 ), ( 187, 119, 48 ), ( 187, 136, 36 ), ( 187, 153, 24 ), ( 187, 170, 12 ),

( 204, 0, 144 ), ( 204, 17, 132 ), ( 204, 34, 120 ), ( 204, 51, 108 ), ( 204, 68, 96 ), ( 204, 85, 84 ), ( 204, 102, 72 ), ( 204, 119, 60 ), ( 204, 136, 48 ), ( 204, 153, 36 ), ( 204, 170, 24 ), ( 204, 187, 12 ),

( 221, 0, 156 ), ( 221, 17, 144 ), ( 221, 34, 132 ), ( 221, 51, 120 ), ( 221, 68, 108 ), ( 221, 85, 96 ), ( 221, 102, 84 ), ( 221, 119, 72 ), ( 221, 136, 60 ), ( 221, 153, 48 ), ( 221, 170, 36 ), ( 221, 187, 24 ), ( 221, 204, 12 ),

( 238, 0, 168 ), ( 238, 17, 156 ), ( 238, 34, 144 ), ( 238, 51, 132 ), ( 238, 68, 120 ), ( 238, 85, 108 ), ( 238, 102, 96 ), ( 238, 119, 84 ), ( 238, 136, 72 ), ( 238, 153, 60 ), ( 238, 170, 48 ), ( 238, 187, 36 ), ( 238, 204, 24 ), ( 238, 221, 12 ),

...

}

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)