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

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

( 15, 0, 8 ),

( 30, 0, 16 ), ( 30, 15, 8 ),

( 45, 0, 24 ), ( 45, 15, 16 ), ( 45, 30, 8 ),

( 60, 0, 32 ), ( 60, 15, 24 ), ( 60, 30, 16 ), ( 60, 45, 8 ),

( 75, 0, 40 ), ( 75, 15, 32 ), ( 75, 30, 24 ), ( 75, 45, 16 ), ( 75, 60, 8 ),

( 90, 0, 48 ), ( 90, 15, 40 ), ( 90, 30, 32 ), ( 90, 45, 24 ), ( 90, 60, 16 ), ( 90, 75, 8 ),

( 105, 0, 56 ), ( 105, 15, 48 ), ( 105, 30, 40 ), ( 105, 45, 32 ), ( 105, 60, 24 ), ( 105, 75, 16 ), ( 105, 90, 8 ),

( 120, 0, 64 ), ( 120, 15, 56 ), ( 120, 30, 48 ), ( 120, 45, 40 ), ( 120, 60, 32 ), ( 120, 75, 24 ), ( 120, 90, 16 ), ( 120, 105, 8 ),

( 135, 0, 72 ), ( 135, 15, 64 ), ( 135, 30, 56 ), ( 135, 45, 48 ), ( 135, 60, 40 ), ( 135, 75, 32 ), ( 135, 90, 24 ), ( 135, 105, 16 ), ( 135, 120, 8 ),

( 150, 0, 80 ), ( 150, 15, 72 ), ( 150, 30, 64 ), ( 150, 45, 56 ), ( 150, 60, 48 ), ( 150, 75, 40 ), ( 150, 90, 32 ), ( 150, 105, 24 ), ( 150, 120, 16 ), ( 150, 135, 8 ),

( 165, 0, 88 ), ( 165, 15, 80 ), ( 165, 30, 72 ), ( 165, 45, 64 ), ( 165, 60, 56 ), ( 165, 75, 48 ), ( 165, 90, 40 ), ( 165, 105, 32 ), ( 165, 120, 24 ), ( 165, 135, 16 ), ( 165, 150, 8 ),

( 180, 0, 96 ), ( 180, 15, 88 ), ( 180, 30, 80 ), ( 180, 45, 72 ), ( 180, 60, 64 ), ( 180, 75, 56 ), ( 180, 90, 48 ), ( 180, 105, 40 ), ( 180, 120, 32 ), ( 180, 135, 24 ), ( 180, 150, 16 ), ( 180, 165, 8 ),

( 195, 0, 104 ), ( 195, 15, 96 ), ( 195, 30, 88 ), ( 195, 45, 80 ), ( 195, 60, 72 ), ( 195, 75, 64 ), ( 195, 90, 56 ), ( 195, 105, 48 ), ( 195, 120, 40 ), ( 195, 135, 32 ), ( 195, 150, 24 ), ( 195, 165, 16 ), ( 195, 180, 8 ),

( 210, 0, 112 ), ( 210, 15, 104 ), ( 210, 30, 96 ), ( 210, 45, 88 ), ( 210, 60, 80 ), ( 210, 75, 72 ), ( 210, 90, 64 ), ( 210, 105, 56 ), ( 210, 120, 48 ), ( 210, 135, 40 ), ( 210, 150, 32 ), ( 210, 165, 24 ), ( 210, 180, 16 ), ( 210, 195, 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)