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

( 19, 0, 13 ),

( 38, 0, 26 ), ( 38, 19, 13 ),

( 57, 0, 39 ), ( 57, 19, 26 ), ( 57, 38, 13 ),

( 76, 0, 52 ), ( 76, 19, 39 ), ( 76, 38, 26 ), ( 76, 57, 13 ),

( 95, 0, 65 ), ( 95, 19, 52 ), ( 95, 38, 39 ), ( 95, 57, 26 ), ( 95, 76, 13 ),

( 114, 0, 78 ), ( 114, 19, 65 ), ( 114, 38, 52 ), ( 114, 57, 39 ), ( 114, 76, 26 ), ( 114, 95, 13 ),

( 133, 0, 91 ), ( 133, 19, 78 ), ( 133, 38, 65 ), ( 133, 57, 52 ), ( 133, 76, 39 ), ( 133, 95, 26 ), ( 133, 114, 13 ),

( 152, 0, 104 ), ( 152, 19, 91 ), ( 152, 38, 78 ), ( 152, 57, 65 ), ( 152, 76, 52 ), ( 152, 95, 39 ), ( 152, 114, 26 ), ( 152, 133, 13 ),

( 171, 0, 117 ), ( 171, 19, 104 ), ( 171, 38, 91 ), ( 171, 57, 78 ), ( 171, 76, 65 ), ( 171, 95, 52 ), ( 171, 114, 39 ), ( 171, 133, 26 ), ( 171, 152, 13 ),

( 190, 0, 130 ), ( 190, 19, 117 ), ( 190, 38, 104 ), ( 190, 57, 91 ), ( 190, 76, 78 ), ( 190, 95, 65 ), ( 190, 114, 52 ), ( 190, 133, 39 ), ( 190, 152, 26 ), ( 190, 171, 13 ),

( 209, 0, 143 ), ( 209, 19, 130 ), ( 209, 38, 117 ), ( 209, 57, 104 ), ( 209, 76, 91 ), ( 209, 95, 78 ), ( 209, 114, 65 ), ( 209, 133, 52 ), ( 209, 152, 39 ), ( 209, 171, 26 ), ( 209, 190, 13 ),

( 228, 0, 156 ), ( 228, 19, 143 ), ( 228, 38, 130 ), ( 228, 57, 117 ), ( 228, 76, 104 ), ( 228, 95, 91 ), ( 228, 114, 78 ), ( 228, 133, 65 ), ( 228, 152, 52 ), ( 228, 171, 39 ), ( 228, 190, 26 ), ( 228, 209, 13 ),

( 247, 0, 169 ), ( 247, 19, 156 ), ( 247, 38, 143 ), ( 247, 57, 130 ), ( 247, 76, 117 ), ( 247, 95, 104 ), ( 247, 114, 91 ), ( 247, 133, 78 ), ( 247, 152, 65 ), ( 247, 171, 52 ), ( 247, 190, 39 ), ( 247, 209, 26 ), ( 247, 228, 13 ),

( 266, 0, 182 ), ( 266, 19, 169 ), ( 266, 38, 156 ), ( 266, 57, 143 ), ( 266, 76, 130 ), ( 266, 95, 117 ), ( 266, 114, 104 ), ( 266, 133, 91 ), ( 266, 152, 78 ), ( 266, 171, 65 ), ( 266, 190, 52 ), ( 266, 209, 39 ), ( 266, 228, 26 ), ( 266, 247, 13 ),

...

}

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)