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

( 30, 0, 19 ),

( 60, 0, 38 ), ( 60, 30, 19 ),

( 90, 0, 57 ), ( 90, 30, 38 ), ( 90, 60, 19 ),

( 120, 0, 76 ), ( 120, 30, 57 ), ( 120, 60, 38 ), ( 120, 90, 19 ),

( 150, 0, 95 ), ( 150, 30, 76 ), ( 150, 60, 57 ), ( 150, 90, 38 ), ( 150, 120, 19 ),

( 180, 0, 114 ), ( 180, 30, 95 ), ( 180, 60, 76 ), ( 180, 90, 57 ), ( 180, 120, 38 ), ( 180, 150, 19 ),

( 210, 0, 133 ), ( 210, 30, 114 ), ( 210, 60, 95 ), ( 210, 90, 76 ), ( 210, 120, 57 ), ( 210, 150, 38 ), ( 210, 180, 19 ),

( 240, 0, 152 ), ( 240, 30, 133 ), ( 240, 60, 114 ), ( 240, 90, 95 ), ( 240, 120, 76 ), ( 240, 150, 57 ), ( 240, 180, 38 ), ( 240, 210, 19 ),

( 270, 0, 171 ), ( 270, 30, 152 ), ( 270, 60, 133 ), ( 270, 90, 114 ), ( 270, 120, 95 ), ( 270, 150, 76 ), ( 270, 180, 57 ), ( 270, 210, 38 ), ( 270, 240, 19 ),

( 300, 0, 190 ), ( 300, 30, 171 ), ( 300, 60, 152 ), ( 300, 90, 133 ), ( 300, 120, 114 ), ( 300, 150, 95 ), ( 300, 180, 76 ), ( 300, 210, 57 ), ( 300, 240, 38 ), ( 300, 270, 19 ),

( 330, 0, 209 ), ( 330, 30, 190 ), ( 330, 60, 171 ), ( 330, 90, 152 ), ( 330, 120, 133 ), ( 330, 150, 114 ), ( 330, 180, 95 ), ( 330, 210, 76 ), ( 330, 240, 57 ), ( 330, 270, 38 ), ( 330, 300, 19 ),

( 360, 0, 228 ), ( 360, 30, 209 ), ( 360, 60, 190 ), ( 360, 90, 171 ), ( 360, 120, 152 ), ( 360, 150, 133 ), ( 360, 180, 114 ), ( 360, 210, 95 ), ( 360, 240, 76 ), ( 360, 270, 57 ), ( 360, 300, 38 ), ( 360, 330, 19 ),

( 390, 0, 247 ), ( 390, 30, 228 ), ( 390, 60, 209 ), ( 390, 90, 190 ), ( 390, 120, 171 ), ( 390, 150, 152 ), ( 390, 180, 133 ), ( 390, 210, 114 ), ( 390, 240, 95 ), ( 390, 270, 76 ), ( 390, 300, 57 ), ( 390, 330, 38 ), ( 390, 360, 19 ),

( 420, 0, 266 ), ( 420, 30, 247 ), ( 420, 60, 228 ), ( 420, 90, 209 ), ( 420, 120, 190 ), ( 420, 150, 171 ), ( 420, 180, 152 ), ( 420, 210, 133 ), ( 420, 240, 114 ), ( 420, 270, 95 ), ( 420, 300, 76 ), ( 420, 330, 57 ), ( 420, 360, 38 ), ( 420, 390, 19 ),

...

}

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)