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

13/4 = (13-0)/4 = {

( 13, 0, 4 ),

( 26, 0, 8 ), ( 26, 13, 4 ),

( 39, 0, 12 ), ( 39, 13, 8 ), ( 39, 26, 4 ),

( 52, 0, 16 ), ( 52, 13, 12 ), ( 52, 26, 8 ), ( 52, 39, 4 ),

( 65, 0, 20 ), ( 65, 13, 16 ), ( 65, 26, 12 ), ( 65, 39, 8 ), ( 65, 52, 4 ),

( 78, 0, 24 ), ( 78, 13, 20 ), ( 78, 26, 16 ), ( 78, 39, 12 ), ( 78, 52, 8 ), ( 78, 65, 4 ),

( 91, 0, 28 ), ( 91, 13, 24 ), ( 91, 26, 20 ), ( 91, 39, 16 ), ( 91, 52, 12 ), ( 91, 65, 8 ), ( 91, 78, 4 ),

( 104, 0, 32 ), ( 104, 13, 28 ), ( 104, 26, 24 ), ( 104, 39, 20 ), ( 104, 52, 16 ), ( 104, 65, 12 ), ( 104, 78, 8 ), ( 104, 91, 4 ),

( 117, 0, 36 ), ( 117, 13, 32 ), ( 117, 26, 28 ), ( 117, 39, 24 ), ( 117, 52, 20 ), ( 117, 65, 16 ), ( 117, 78, 12 ), ( 117, 91, 8 ), ( 117, 104, 4 ),

( 130, 0, 40 ), ( 130, 13, 36 ), ( 130, 26, 32 ), ( 130, 39, 28 ), ( 130, 52, 24 ), ( 130, 65, 20 ), ( 130, 78, 16 ), ( 130, 91, 12 ), ( 130, 104, 8 ), ( 130, 117, 4 ),

( 143, 0, 44 ), ( 143, 13, 40 ), ( 143, 26, 36 ), ( 143, 39, 32 ), ( 143, 52, 28 ), ( 143, 65, 24 ), ( 143, 78, 20 ), ( 143, 91, 16 ), ( 143, 104, 12 ), ( 143, 117, 8 ), ( 143, 130, 4 ),

( 156, 0, 48 ), ( 156, 13, 44 ), ( 156, 26, 40 ), ( 156, 39, 36 ), ( 156, 52, 32 ), ( 156, 65, 28 ), ( 156, 78, 24 ), ( 156, 91, 20 ), ( 156, 104, 16 ), ( 156, 117, 12 ), ( 156, 130, 8 ), ( 156, 143, 4 ),

( 169, 0, 52 ), ( 169, 13, 48 ), ( 169, 26, 44 ), ( 169, 39, 40 ), ( 169, 52, 36 ), ( 169, 65, 32 ), ( 169, 78, 28 ), ( 169, 91, 24 ), ( 169, 104, 20 ), ( 169, 117, 16 ), ( 169, 130, 12 ), ( 169, 143, 8 ), ( 169, 156, 4 ),

( 182, 0, 56 ), ( 182, 13, 52 ), ( 182, 26, 48 ), ( 182, 39, 44 ), ( 182, 52, 40 ), ( 182, 65, 36 ), ( 182, 78, 32 ), ( 182, 91, 28 ), ( 182, 104, 24 ), ( 182, 117, 20 ), ( 182, 130, 16 ), ( 182, 143, 12 ), ( 182, 156, 8 ), ( 182, 169, 4 ),

...

}

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)