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

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

( 17, 0, 7 ),

( 34, 0, 14 ), ( 34, 17, 7 ),

( 51, 0, 21 ), ( 51, 17, 14 ), ( 51, 34, 7 ),

( 68, 0, 28 ), ( 68, 17, 21 ), ( 68, 34, 14 ), ( 68, 51, 7 ),

( 85, 0, 35 ), ( 85, 17, 28 ), ( 85, 34, 21 ), ( 85, 51, 14 ), ( 85, 68, 7 ),

( 102, 0, 42 ), ( 102, 17, 35 ), ( 102, 34, 28 ), ( 102, 51, 21 ), ( 102, 68, 14 ), ( 102, 85, 7 ),

( 119, 0, 49 ), ( 119, 17, 42 ), ( 119, 34, 35 ), ( 119, 51, 28 ), ( 119, 68, 21 ), ( 119, 85, 14 ), ( 119, 102, 7 ),

( 136, 0, 56 ), ( 136, 17, 49 ), ( 136, 34, 42 ), ( 136, 51, 35 ), ( 136, 68, 28 ), ( 136, 85, 21 ), ( 136, 102, 14 ), ( 136, 119, 7 ),

( 153, 0, 63 ), ( 153, 17, 56 ), ( 153, 34, 49 ), ( 153, 51, 42 ), ( 153, 68, 35 ), ( 153, 85, 28 ), ( 153, 102, 21 ), ( 153, 119, 14 ), ( 153, 136, 7 ),

( 170, 0, 70 ), ( 170, 17, 63 ), ( 170, 34, 56 ), ( 170, 51, 49 ), ( 170, 68, 42 ), ( 170, 85, 35 ), ( 170, 102, 28 ), ( 170, 119, 21 ), ( 170, 136, 14 ), ( 170, 153, 7 ),

( 187, 0, 77 ), ( 187, 17, 70 ), ( 187, 34, 63 ), ( 187, 51, 56 ), ( 187, 68, 49 ), ( 187, 85, 42 ), ( 187, 102, 35 ), ( 187, 119, 28 ), ( 187, 136, 21 ), ( 187, 153, 14 ), ( 187, 170, 7 ),

( 204, 0, 84 ), ( 204, 17, 77 ), ( 204, 34, 70 ), ( 204, 51, 63 ), ( 204, 68, 56 ), ( 204, 85, 49 ), ( 204, 102, 42 ), ( 204, 119, 35 ), ( 204, 136, 28 ), ( 204, 153, 21 ), ( 204, 170, 14 ), ( 204, 187, 7 ),

( 221, 0, 91 ), ( 221, 17, 84 ), ( 221, 34, 77 ), ( 221, 51, 70 ), ( 221, 68, 63 ), ( 221, 85, 56 ), ( 221, 102, 49 ), ( 221, 119, 42 ), ( 221, 136, 35 ), ( 221, 153, 28 ), ( 221, 170, 21 ), ( 221, 187, 14 ), ( 221, 204, 7 ),

( 238, 0, 98 ), ( 238, 17, 91 ), ( 238, 34, 84 ), ( 238, 51, 77 ), ( 238, 68, 70 ), ( 238, 85, 63 ), ( 238, 102, 56 ), ( 238, 119, 49 ), ( 238, 136, 42 ), ( 238, 153, 35 ), ( 238, 170, 28 ), ( 238, 187, 21 ), ( 238, 204, 14 ), ( 238, 221, 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)