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

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

( 19, 0, 4 ),

( 38, 0, 8 ), ( 38, 19, 4 ),

( 57, 0, 12 ), ( 57, 19, 8 ), ( 57, 38, 4 ),

( 76, 0, 16 ), ( 76, 19, 12 ), ( 76, 38, 8 ), ( 76, 57, 4 ),

( 95, 0, 20 ), ( 95, 19, 16 ), ( 95, 38, 12 ), ( 95, 57, 8 ), ( 95, 76, 4 ),

( 114, 0, 24 ), ( 114, 19, 20 ), ( 114, 38, 16 ), ( 114, 57, 12 ), ( 114, 76, 8 ), ( 114, 95, 4 ),

( 133, 0, 28 ), ( 133, 19, 24 ), ( 133, 38, 20 ), ( 133, 57, 16 ), ( 133, 76, 12 ), ( 133, 95, 8 ), ( 133, 114, 4 ),

( 152, 0, 32 ), ( 152, 19, 28 ), ( 152, 38, 24 ), ( 152, 57, 20 ), ( 152, 76, 16 ), ( 152, 95, 12 ), ( 152, 114, 8 ), ( 152, 133, 4 ),

( 171, 0, 36 ), ( 171, 19, 32 ), ( 171, 38, 28 ), ( 171, 57, 24 ), ( 171, 76, 20 ), ( 171, 95, 16 ), ( 171, 114, 12 ), ( 171, 133, 8 ), ( 171, 152, 4 ),

( 190, 0, 40 ), ( 190, 19, 36 ), ( 190, 38, 32 ), ( 190, 57, 28 ), ( 190, 76, 24 ), ( 190, 95, 20 ), ( 190, 114, 16 ), ( 190, 133, 12 ), ( 190, 152, 8 ), ( 190, 171, 4 ),

( 209, 0, 44 ), ( 209, 19, 40 ), ( 209, 38, 36 ), ( 209, 57, 32 ), ( 209, 76, 28 ), ( 209, 95, 24 ), ( 209, 114, 20 ), ( 209, 133, 16 ), ( 209, 152, 12 ), ( 209, 171, 8 ), ( 209, 190, 4 ),

( 228, 0, 48 ), ( 228, 19, 44 ), ( 228, 38, 40 ), ( 228, 57, 36 ), ( 228, 76, 32 ), ( 228, 95, 28 ), ( 228, 114, 24 ), ( 228, 133, 20 ), ( 228, 152, 16 ), ( 228, 171, 12 ), ( 228, 190, 8 ), ( 228, 209, 4 ),

( 247, 0, 52 ), ( 247, 19, 48 ), ( 247, 38, 44 ), ( 247, 57, 40 ), ( 247, 76, 36 ), ( 247, 95, 32 ), ( 247, 114, 28 ), ( 247, 133, 24 ), ( 247, 152, 20 ), ( 247, 171, 16 ), ( 247, 190, 12 ), ( 247, 209, 8 ), ( 247, 228, 4 ),

( 266, 0, 56 ), ( 266, 19, 52 ), ( 266, 38, 48 ), ( 266, 57, 44 ), ( 266, 76, 40 ), ( 266, 95, 36 ), ( 266, 114, 32 ), ( 266, 133, 28 ), ( 266, 152, 24 ), ( 266, 171, 20 ), ( 266, 190, 16 ), ( 266, 209, 12 ), ( 266, 228, 8 ), ( 266, 247, 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)