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

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

( 9, 0, 4 ),

( 18, 0, 8 ), ( 18, 9, 4 ),

( 27, 0, 12 ), ( 27, 9, 8 ), ( 27, 18, 4 ),

( 36, 0, 16 ), ( 36, 9, 12 ), ( 36, 18, 8 ), ( 36, 27, 4 ),

( 45, 0, 20 ), ( 45, 9, 16 ), ( 45, 18, 12 ), ( 45, 27, 8 ), ( 45, 36, 4 ),

( 54, 0, 24 ), ( 54, 9, 20 ), ( 54, 18, 16 ), ( 54, 27, 12 ), ( 54, 36, 8 ), ( 54, 45, 4 ),

( 63, 0, 28 ), ( 63, 9, 24 ), ( 63, 18, 20 ), ( 63, 27, 16 ), ( 63, 36, 12 ), ( 63, 45, 8 ), ( 63, 54, 4 ),

( 72, 0, 32 ), ( 72, 9, 28 ), ( 72, 18, 24 ), ( 72, 27, 20 ), ( 72, 36, 16 ), ( 72, 45, 12 ), ( 72, 54, 8 ), ( 72, 63, 4 ),

( 81, 0, 36 ), ( 81, 9, 32 ), ( 81, 18, 28 ), ( 81, 27, 24 ), ( 81, 36, 20 ), ( 81, 45, 16 ), ( 81, 54, 12 ), ( 81, 63, 8 ), ( 81, 72, 4 ),

( 90, 0, 40 ), ( 90, 9, 36 ), ( 90, 18, 32 ), ( 90, 27, 28 ), ( 90, 36, 24 ), ( 90, 45, 20 ), ( 90, 54, 16 ), ( 90, 63, 12 ), ( 90, 72, 8 ), ( 90, 81, 4 ),

( 99, 0, 44 ), ( 99, 9, 40 ), ( 99, 18, 36 ), ( 99, 27, 32 ), ( 99, 36, 28 ), ( 99, 45, 24 ), ( 99, 54, 20 ), ( 99, 63, 16 ), ( 99, 72, 12 ), ( 99, 81, 8 ), ( 99, 90, 4 ),

( 108, 0, 48 ), ( 108, 9, 44 ), ( 108, 18, 40 ), ( 108, 27, 36 ), ( 108, 36, 32 ), ( 108, 45, 28 ), ( 108, 54, 24 ), ( 108, 63, 20 ), ( 108, 72, 16 ), ( 108, 81, 12 ), ( 108, 90, 8 ), ( 108, 99, 4 ),

( 117, 0, 52 ), ( 117, 9, 48 ), ( 117, 18, 44 ), ( 117, 27, 40 ), ( 117, 36, 36 ), ( 117, 45, 32 ), ( 117, 54, 28 ), ( 117, 63, 24 ), ( 117, 72, 20 ), ( 117, 81, 16 ), ( 117, 90, 12 ), ( 117, 99, 8 ), ( 117, 108, 4 ),

( 126, 0, 56 ), ( 126, 9, 52 ), ( 126, 18, 48 ), ( 126, 27, 44 ), ( 126, 36, 40 ), ( 126, 45, 36 ), ( 126, 54, 32 ), ( 126, 63, 28 ), ( 126, 72, 24 ), ( 126, 81, 20 ), ( 126, 90, 16 ), ( 126, 99, 12 ), ( 126, 108, 8 ), ( 126, 117, 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)