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

( 15, 0, 7 ),

( 30, 0, 14 ), ( 30, 15, 7 ),

( 45, 0, 21 ), ( 45, 15, 14 ), ( 45, 30, 7 ),

( 60, 0, 28 ), ( 60, 15, 21 ), ( 60, 30, 14 ), ( 60, 45, 7 ),

( 75, 0, 35 ), ( 75, 15, 28 ), ( 75, 30, 21 ), ( 75, 45, 14 ), ( 75, 60, 7 ),

( 90, 0, 42 ), ( 90, 15, 35 ), ( 90, 30, 28 ), ( 90, 45, 21 ), ( 90, 60, 14 ), ( 90, 75, 7 ),

( 105, 0, 49 ), ( 105, 15, 42 ), ( 105, 30, 35 ), ( 105, 45, 28 ), ( 105, 60, 21 ), ( 105, 75, 14 ), ( 105, 90, 7 ),

( 120, 0, 56 ), ( 120, 15, 49 ), ( 120, 30, 42 ), ( 120, 45, 35 ), ( 120, 60, 28 ), ( 120, 75, 21 ), ( 120, 90, 14 ), ( 120, 105, 7 ),

( 135, 0, 63 ), ( 135, 15, 56 ), ( 135, 30, 49 ), ( 135, 45, 42 ), ( 135, 60, 35 ), ( 135, 75, 28 ), ( 135, 90, 21 ), ( 135, 105, 14 ), ( 135, 120, 7 ),

( 150, 0, 70 ), ( 150, 15, 63 ), ( 150, 30, 56 ), ( 150, 45, 49 ), ( 150, 60, 42 ), ( 150, 75, 35 ), ( 150, 90, 28 ), ( 150, 105, 21 ), ( 150, 120, 14 ), ( 150, 135, 7 ),

( 165, 0, 77 ), ( 165, 15, 70 ), ( 165, 30, 63 ), ( 165, 45, 56 ), ( 165, 60, 49 ), ( 165, 75, 42 ), ( 165, 90, 35 ), ( 165, 105, 28 ), ( 165, 120, 21 ), ( 165, 135, 14 ), ( 165, 150, 7 ),

( 180, 0, 84 ), ( 180, 15, 77 ), ( 180, 30, 70 ), ( 180, 45, 63 ), ( 180, 60, 56 ), ( 180, 75, 49 ), ( 180, 90, 42 ), ( 180, 105, 35 ), ( 180, 120, 28 ), ( 180, 135, 21 ), ( 180, 150, 14 ), ( 180, 165, 7 ),

( 195, 0, 91 ), ( 195, 15, 84 ), ( 195, 30, 77 ), ( 195, 45, 70 ), ( 195, 60, 63 ), ( 195, 75, 56 ), ( 195, 90, 49 ), ( 195, 105, 42 ), ( 195, 120, 35 ), ( 195, 135, 28 ), ( 195, 150, 21 ), ( 195, 165, 14 ), ( 195, 180, 7 ),

( 210, 0, 98 ), ( 210, 15, 91 ), ( 210, 30, 84 ), ( 210, 45, 77 ), ( 210, 60, 70 ), ( 210, 75, 63 ), ( 210, 90, 56 ), ( 210, 105, 49 ), ( 210, 120, 42 ), ( 210, 135, 35 ), ( 210, 150, 28 ), ( 210, 165, 21 ), ( 210, 180, 14 ), ( 210, 195, 7 ),

...

}

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)