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

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

( 19, 0, 8 ),

( 38, 0, 16 ), ( 38, 19, 8 ),

( 57, 0, 24 ), ( 57, 19, 16 ), ( 57, 38, 8 ),

( 76, 0, 32 ), ( 76, 19, 24 ), ( 76, 38, 16 ), ( 76, 57, 8 ),

( 95, 0, 40 ), ( 95, 19, 32 ), ( 95, 38, 24 ), ( 95, 57, 16 ), ( 95, 76, 8 ),

( 114, 0, 48 ), ( 114, 19, 40 ), ( 114, 38, 32 ), ( 114, 57, 24 ), ( 114, 76, 16 ), ( 114, 95, 8 ),

( 133, 0, 56 ), ( 133, 19, 48 ), ( 133, 38, 40 ), ( 133, 57, 32 ), ( 133, 76, 24 ), ( 133, 95, 16 ), ( 133, 114, 8 ),

( 152, 0, 64 ), ( 152, 19, 56 ), ( 152, 38, 48 ), ( 152, 57, 40 ), ( 152, 76, 32 ), ( 152, 95, 24 ), ( 152, 114, 16 ), ( 152, 133, 8 ),

( 171, 0, 72 ), ( 171, 19, 64 ), ( 171, 38, 56 ), ( 171, 57, 48 ), ( 171, 76, 40 ), ( 171, 95, 32 ), ( 171, 114, 24 ), ( 171, 133, 16 ), ( 171, 152, 8 ),

( 190, 0, 80 ), ( 190, 19, 72 ), ( 190, 38, 64 ), ( 190, 57, 56 ), ( 190, 76, 48 ), ( 190, 95, 40 ), ( 190, 114, 32 ), ( 190, 133, 24 ), ( 190, 152, 16 ), ( 190, 171, 8 ),

( 209, 0, 88 ), ( 209, 19, 80 ), ( 209, 38, 72 ), ( 209, 57, 64 ), ( 209, 76, 56 ), ( 209, 95, 48 ), ( 209, 114, 40 ), ( 209, 133, 32 ), ( 209, 152, 24 ), ( 209, 171, 16 ), ( 209, 190, 8 ),

( 228, 0, 96 ), ( 228, 19, 88 ), ( 228, 38, 80 ), ( 228, 57, 72 ), ( 228, 76, 64 ), ( 228, 95, 56 ), ( 228, 114, 48 ), ( 228, 133, 40 ), ( 228, 152, 32 ), ( 228, 171, 24 ), ( 228, 190, 16 ), ( 228, 209, 8 ),

( 247, 0, 104 ), ( 247, 19, 96 ), ( 247, 38, 88 ), ( 247, 57, 80 ), ( 247, 76, 72 ), ( 247, 95, 64 ), ( 247, 114, 56 ), ( 247, 133, 48 ), ( 247, 152, 40 ), ( 247, 171, 32 ), ( 247, 190, 24 ), ( 247, 209, 16 ), ( 247, 228, 8 ),

( 266, 0, 112 ), ( 266, 19, 104 ), ( 266, 38, 96 ), ( 266, 57, 88 ), ( 266, 76, 80 ), ( 266, 95, 72 ), ( 266, 114, 64 ), ( 266, 133, 56 ), ( 266, 152, 48 ), ( 266, 171, 40 ), ( 266, 190, 32 ), ( 266, 209, 24 ), ( 266, 228, 16 ), ( 266, 247, 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)