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

( 17, 0, 8 ),

( 34, 0, 16 ), ( 34, 17, 8 ),

( 51, 0, 24 ), ( 51, 17, 16 ), ( 51, 34, 8 ),

( 68, 0, 32 ), ( 68, 17, 24 ), ( 68, 34, 16 ), ( 68, 51, 8 ),

( 85, 0, 40 ), ( 85, 17, 32 ), ( 85, 34, 24 ), ( 85, 51, 16 ), ( 85, 68, 8 ),

( 102, 0, 48 ), ( 102, 17, 40 ), ( 102, 34, 32 ), ( 102, 51, 24 ), ( 102, 68, 16 ), ( 102, 85, 8 ),

( 119, 0, 56 ), ( 119, 17, 48 ), ( 119, 34, 40 ), ( 119, 51, 32 ), ( 119, 68, 24 ), ( 119, 85, 16 ), ( 119, 102, 8 ),

( 136, 0, 64 ), ( 136, 17, 56 ), ( 136, 34, 48 ), ( 136, 51, 40 ), ( 136, 68, 32 ), ( 136, 85, 24 ), ( 136, 102, 16 ), ( 136, 119, 8 ),

( 153, 0, 72 ), ( 153, 17, 64 ), ( 153, 34, 56 ), ( 153, 51, 48 ), ( 153, 68, 40 ), ( 153, 85, 32 ), ( 153, 102, 24 ), ( 153, 119, 16 ), ( 153, 136, 8 ),

( 170, 0, 80 ), ( 170, 17, 72 ), ( 170, 34, 64 ), ( 170, 51, 56 ), ( 170, 68, 48 ), ( 170, 85, 40 ), ( 170, 102, 32 ), ( 170, 119, 24 ), ( 170, 136, 16 ), ( 170, 153, 8 ),

( 187, 0, 88 ), ( 187, 17, 80 ), ( 187, 34, 72 ), ( 187, 51, 64 ), ( 187, 68, 56 ), ( 187, 85, 48 ), ( 187, 102, 40 ), ( 187, 119, 32 ), ( 187, 136, 24 ), ( 187, 153, 16 ), ( 187, 170, 8 ),

( 204, 0, 96 ), ( 204, 17, 88 ), ( 204, 34, 80 ), ( 204, 51, 72 ), ( 204, 68, 64 ), ( 204, 85, 56 ), ( 204, 102, 48 ), ( 204, 119, 40 ), ( 204, 136, 32 ), ( 204, 153, 24 ), ( 204, 170, 16 ), ( 204, 187, 8 ),

( 221, 0, 104 ), ( 221, 17, 96 ), ( 221, 34, 88 ), ( 221, 51, 80 ), ( 221, 68, 72 ), ( 221, 85, 64 ), ( 221, 102, 56 ), ( 221, 119, 48 ), ( 221, 136, 40 ), ( 221, 153, 32 ), ( 221, 170, 24 ), ( 221, 187, 16 ), ( 221, 204, 8 ),

( 238, 0, 112 ), ( 238, 17, 104 ), ( 238, 34, 96 ), ( 238, 51, 88 ), ( 238, 68, 80 ), ( 238, 85, 72 ), ( 238, 102, 64 ), ( 238, 119, 56 ), ( 238, 136, 48 ), ( 238, 153, 40 ), ( 238, 170, 32 ), ( 238, 187, 24 ), ( 238, 204, 16 ), ( 238, 221, 8 ),

...

}

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)