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

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

( 19, 0, 12 ),

( 38, 0, 24 ), ( 38, 19, 12 ),

( 57, 0, 36 ), ( 57, 19, 24 ), ( 57, 38, 12 ),

( 76, 0, 48 ), ( 76, 19, 36 ), ( 76, 38, 24 ), ( 76, 57, 12 ),

( 95, 0, 60 ), ( 95, 19, 48 ), ( 95, 38, 36 ), ( 95, 57, 24 ), ( 95, 76, 12 ),

( 114, 0, 72 ), ( 114, 19, 60 ), ( 114, 38, 48 ), ( 114, 57, 36 ), ( 114, 76, 24 ), ( 114, 95, 12 ),

( 133, 0, 84 ), ( 133, 19, 72 ), ( 133, 38, 60 ), ( 133, 57, 48 ), ( 133, 76, 36 ), ( 133, 95, 24 ), ( 133, 114, 12 ),

( 152, 0, 96 ), ( 152, 19, 84 ), ( 152, 38, 72 ), ( 152, 57, 60 ), ( 152, 76, 48 ), ( 152, 95, 36 ), ( 152, 114, 24 ), ( 152, 133, 12 ),

( 171, 0, 108 ), ( 171, 19, 96 ), ( 171, 38, 84 ), ( 171, 57, 72 ), ( 171, 76, 60 ), ( 171, 95, 48 ), ( 171, 114, 36 ), ( 171, 133, 24 ), ( 171, 152, 12 ),

( 190, 0, 120 ), ( 190, 19, 108 ), ( 190, 38, 96 ), ( 190, 57, 84 ), ( 190, 76, 72 ), ( 190, 95, 60 ), ( 190, 114, 48 ), ( 190, 133, 36 ), ( 190, 152, 24 ), ( 190, 171, 12 ),

( 209, 0, 132 ), ( 209, 19, 120 ), ( 209, 38, 108 ), ( 209, 57, 96 ), ( 209, 76, 84 ), ( 209, 95, 72 ), ( 209, 114, 60 ), ( 209, 133, 48 ), ( 209, 152, 36 ), ( 209, 171, 24 ), ( 209, 190, 12 ),

( 228, 0, 144 ), ( 228, 19, 132 ), ( 228, 38, 120 ), ( 228, 57, 108 ), ( 228, 76, 96 ), ( 228, 95, 84 ), ( 228, 114, 72 ), ( 228, 133, 60 ), ( 228, 152, 48 ), ( 228, 171, 36 ), ( 228, 190, 24 ), ( 228, 209, 12 ),

( 247, 0, 156 ), ( 247, 19, 144 ), ( 247, 38, 132 ), ( 247, 57, 120 ), ( 247, 76, 108 ), ( 247, 95, 96 ), ( 247, 114, 84 ), ( 247, 133, 72 ), ( 247, 152, 60 ), ( 247, 171, 48 ), ( 247, 190, 36 ), ( 247, 209, 24 ), ( 247, 228, 12 ),

( 266, 0, 168 ), ( 266, 19, 156 ), ( 266, 38, 144 ), ( 266, 57, 132 ), ( 266, 76, 120 ), ( 266, 95, 108 ), ( 266, 114, 96 ), ( 266, 133, 84 ), ( 266, 152, 72 ), ( 266, 171, 60 ), ( 266, 190, 48 ), ( 266, 209, 36 ), ( 266, 228, 24 ), ( 266, 247, 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)