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

30/7 = (30-0)/7 = {

( 30, 0, 7 ),

( 60, 0, 14 ), ( 60, 30, 7 ),

( 90, 0, 21 ), ( 90, 30, 14 ), ( 90, 60, 7 ),

( 120, 0, 28 ), ( 120, 30, 21 ), ( 120, 60, 14 ), ( 120, 90, 7 ),

( 150, 0, 35 ), ( 150, 30, 28 ), ( 150, 60, 21 ), ( 150, 90, 14 ), ( 150, 120, 7 ),

( 180, 0, 42 ), ( 180, 30, 35 ), ( 180, 60, 28 ), ( 180, 90, 21 ), ( 180, 120, 14 ), ( 180, 150, 7 ),

( 210, 0, 49 ), ( 210, 30, 42 ), ( 210, 60, 35 ), ( 210, 90, 28 ), ( 210, 120, 21 ), ( 210, 150, 14 ), ( 210, 180, 7 ),

( 240, 0, 56 ), ( 240, 30, 49 ), ( 240, 60, 42 ), ( 240, 90, 35 ), ( 240, 120, 28 ), ( 240, 150, 21 ), ( 240, 180, 14 ), ( 240, 210, 7 ),

( 270, 0, 63 ), ( 270, 30, 56 ), ( 270, 60, 49 ), ( 270, 90, 42 ), ( 270, 120, 35 ), ( 270, 150, 28 ), ( 270, 180, 21 ), ( 270, 210, 14 ), ( 270, 240, 7 ),

( 300, 0, 70 ), ( 300, 30, 63 ), ( 300, 60, 56 ), ( 300, 90, 49 ), ( 300, 120, 42 ), ( 300, 150, 35 ), ( 300, 180, 28 ), ( 300, 210, 21 ), ( 300, 240, 14 ), ( 300, 270, 7 ),

( 330, 0, 77 ), ( 330, 30, 70 ), ( 330, 60, 63 ), ( 330, 90, 56 ), ( 330, 120, 49 ), ( 330, 150, 42 ), ( 330, 180, 35 ), ( 330, 210, 28 ), ( 330, 240, 21 ), ( 330, 270, 14 ), ( 330, 300, 7 ),

( 360, 0, 84 ), ( 360, 30, 77 ), ( 360, 60, 70 ), ( 360, 90, 63 ), ( 360, 120, 56 ), ( 360, 150, 49 ), ( 360, 180, 42 ), ( 360, 210, 35 ), ( 360, 240, 28 ), ( 360, 270, 21 ), ( 360, 300, 14 ), ( 360, 330, 7 ),

( 390, 0, 91 ), ( 390, 30, 84 ), ( 390, 60, 77 ), ( 390, 90, 70 ), ( 390, 120, 63 ), ( 390, 150, 56 ), ( 390, 180, 49 ), ( 390, 210, 42 ), ( 390, 240, 35 ), ( 390, 270, 28 ), ( 390, 300, 21 ), ( 390, 330, 14 ), ( 390, 360, 7 ),

( 420, 0, 98 ), ( 420, 30, 91 ), ( 420, 60, 84 ), ( 420, 90, 77 ), ( 420, 120, 70 ), ( 420, 150, 63 ), ( 420, 180, 56 ), ( 420, 210, 49 ), ( 420, 240, 42 ), ( 420, 270, 35 ), ( 420, 300, 28 ), ( 420, 330, 21 ), ( 420, 360, 14 ), ( 420, 390, 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)