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

19/6 = (19-0)/6 = {

( 19, 0, 6 ),

( 38, 0, 12 ), ( 38, 19, 6 ),

( 57, 0, 18 ), ( 57, 19, 12 ), ( 57, 38, 6 ),

( 76, 0, 24 ), ( 76, 19, 18 ), ( 76, 38, 12 ), ( 76, 57, 6 ),

( 95, 0, 30 ), ( 95, 19, 24 ), ( 95, 38, 18 ), ( 95, 57, 12 ), ( 95, 76, 6 ),

( 114, 0, 36 ), ( 114, 19, 30 ), ( 114, 38, 24 ), ( 114, 57, 18 ), ( 114, 76, 12 ), ( 114, 95, 6 ),

( 133, 0, 42 ), ( 133, 19, 36 ), ( 133, 38, 30 ), ( 133, 57, 24 ), ( 133, 76, 18 ), ( 133, 95, 12 ), ( 133, 114, 6 ),

( 152, 0, 48 ), ( 152, 19, 42 ), ( 152, 38, 36 ), ( 152, 57, 30 ), ( 152, 76, 24 ), ( 152, 95, 18 ), ( 152, 114, 12 ), ( 152, 133, 6 ),

( 171, 0, 54 ), ( 171, 19, 48 ), ( 171, 38, 42 ), ( 171, 57, 36 ), ( 171, 76, 30 ), ( 171, 95, 24 ), ( 171, 114, 18 ), ( 171, 133, 12 ), ( 171, 152, 6 ),

( 190, 0, 60 ), ( 190, 19, 54 ), ( 190, 38, 48 ), ( 190, 57, 42 ), ( 190, 76, 36 ), ( 190, 95, 30 ), ( 190, 114, 24 ), ( 190, 133, 18 ), ( 190, 152, 12 ), ( 190, 171, 6 ),

( 209, 0, 66 ), ( 209, 19, 60 ), ( 209, 38, 54 ), ( 209, 57, 48 ), ( 209, 76, 42 ), ( 209, 95, 36 ), ( 209, 114, 30 ), ( 209, 133, 24 ), ( 209, 152, 18 ), ( 209, 171, 12 ), ( 209, 190, 6 ),

( 228, 0, 72 ), ( 228, 19, 66 ), ( 228, 38, 60 ), ( 228, 57, 54 ), ( 228, 76, 48 ), ( 228, 95, 42 ), ( 228, 114, 36 ), ( 228, 133, 30 ), ( 228, 152, 24 ), ( 228, 171, 18 ), ( 228, 190, 12 ), ( 228, 209, 6 ),

( 247, 0, 78 ), ( 247, 19, 72 ), ( 247, 38, 66 ), ( 247, 57, 60 ), ( 247, 76, 54 ), ( 247, 95, 48 ), ( 247, 114, 42 ), ( 247, 133, 36 ), ( 247, 152, 30 ), ( 247, 171, 24 ), ( 247, 190, 18 ), ( 247, 209, 12 ), ( 247, 228, 6 ),

( 266, 0, 84 ), ( 266, 19, 78 ), ( 266, 38, 72 ), ( 266, 57, 66 ), ( 266, 76, 60 ), ( 266, 95, 54 ), ( 266, 114, 48 ), ( 266, 133, 42 ), ( 266, 152, 36 ), ( 266, 171, 30 ), ( 266, 190, 24 ), ( 266, 209, 18 ), ( 266, 228, 12 ), ( 266, 247, 6 ),

...

}

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)