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

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

( 23, 0, 15 ),

( 46, 0, 30 ), ( 46, 23, 15 ),

( 69, 0, 45 ), ( 69, 23, 30 ), ( 69, 46, 15 ),

( 92, 0, 60 ), ( 92, 23, 45 ), ( 92, 46, 30 ), ( 92, 69, 15 ),

( 115, 0, 75 ), ( 115, 23, 60 ), ( 115, 46, 45 ), ( 115, 69, 30 ), ( 115, 92, 15 ),

( 138, 0, 90 ), ( 138, 23, 75 ), ( 138, 46, 60 ), ( 138, 69, 45 ), ( 138, 92, 30 ), ( 138, 115, 15 ),

( 161, 0, 105 ), ( 161, 23, 90 ), ( 161, 46, 75 ), ( 161, 69, 60 ), ( 161, 92, 45 ), ( 161, 115, 30 ), ( 161, 138, 15 ),

( 184, 0, 120 ), ( 184, 23, 105 ), ( 184, 46, 90 ), ( 184, 69, 75 ), ( 184, 92, 60 ), ( 184, 115, 45 ), ( 184, 138, 30 ), ( 184, 161, 15 ),

( 207, 0, 135 ), ( 207, 23, 120 ), ( 207, 46, 105 ), ( 207, 69, 90 ), ( 207, 92, 75 ), ( 207, 115, 60 ), ( 207, 138, 45 ), ( 207, 161, 30 ), ( 207, 184, 15 ),

( 230, 0, 150 ), ( 230, 23, 135 ), ( 230, 46, 120 ), ( 230, 69, 105 ), ( 230, 92, 90 ), ( 230, 115, 75 ), ( 230, 138, 60 ), ( 230, 161, 45 ), ( 230, 184, 30 ), ( 230, 207, 15 ),

( 253, 0, 165 ), ( 253, 23, 150 ), ( 253, 46, 135 ), ( 253, 69, 120 ), ( 253, 92, 105 ), ( 253, 115, 90 ), ( 253, 138, 75 ), ( 253, 161, 60 ), ( 253, 184, 45 ), ( 253, 207, 30 ), ( 253, 230, 15 ),

( 276, 0, 180 ), ( 276, 23, 165 ), ( 276, 46, 150 ), ( 276, 69, 135 ), ( 276, 92, 120 ), ( 276, 115, 105 ), ( 276, 138, 90 ), ( 276, 161, 75 ), ( 276, 184, 60 ), ( 276, 207, 45 ), ( 276, 230, 30 ), ( 276, 253, 15 ),

( 299, 0, 195 ), ( 299, 23, 180 ), ( 299, 46, 165 ), ( 299, 69, 150 ), ( 299, 92, 135 ), ( 299, 115, 120 ), ( 299, 138, 105 ), ( 299, 161, 90 ), ( 299, 184, 75 ), ( 299, 207, 60 ), ( 299, 230, 45 ), ( 299, 253, 30 ), ( 299, 276, 15 ),

( 322, 0, 210 ), ( 322, 23, 195 ), ( 322, 46, 180 ), ( 322, 69, 165 ), ( 322, 92, 150 ), ( 322, 115, 135 ), ( 322, 138, 120 ), ( 322, 161, 105 ), ( 322, 184, 90 ), ( 322, 207, 75 ), ( 322, 230, 60 ), ( 322, 253, 45 ), ( 322, 276, 30 ), ( 322, 299, 15 ),

...

}

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)