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

( 23, 0, 14 ),

( 46, 0, 28 ), ( 46, 23, 14 ),

( 69, 0, 42 ), ( 69, 23, 28 ), ( 69, 46, 14 ),

( 92, 0, 56 ), ( 92, 23, 42 ), ( 92, 46, 28 ), ( 92, 69, 14 ),

( 115, 0, 70 ), ( 115, 23, 56 ), ( 115, 46, 42 ), ( 115, 69, 28 ), ( 115, 92, 14 ),

( 138, 0, 84 ), ( 138, 23, 70 ), ( 138, 46, 56 ), ( 138, 69, 42 ), ( 138, 92, 28 ), ( 138, 115, 14 ),

( 161, 0, 98 ), ( 161, 23, 84 ), ( 161, 46, 70 ), ( 161, 69, 56 ), ( 161, 92, 42 ), ( 161, 115, 28 ), ( 161, 138, 14 ),

( 184, 0, 112 ), ( 184, 23, 98 ), ( 184, 46, 84 ), ( 184, 69, 70 ), ( 184, 92, 56 ), ( 184, 115, 42 ), ( 184, 138, 28 ), ( 184, 161, 14 ),

( 207, 0, 126 ), ( 207, 23, 112 ), ( 207, 46, 98 ), ( 207, 69, 84 ), ( 207, 92, 70 ), ( 207, 115, 56 ), ( 207, 138, 42 ), ( 207, 161, 28 ), ( 207, 184, 14 ),

( 230, 0, 140 ), ( 230, 23, 126 ), ( 230, 46, 112 ), ( 230, 69, 98 ), ( 230, 92, 84 ), ( 230, 115, 70 ), ( 230, 138, 56 ), ( 230, 161, 42 ), ( 230, 184, 28 ), ( 230, 207, 14 ),

( 253, 0, 154 ), ( 253, 23, 140 ), ( 253, 46, 126 ), ( 253, 69, 112 ), ( 253, 92, 98 ), ( 253, 115, 84 ), ( 253, 138, 70 ), ( 253, 161, 56 ), ( 253, 184, 42 ), ( 253, 207, 28 ), ( 253, 230, 14 ),

( 276, 0, 168 ), ( 276, 23, 154 ), ( 276, 46, 140 ), ( 276, 69, 126 ), ( 276, 92, 112 ), ( 276, 115, 98 ), ( 276, 138, 84 ), ( 276, 161, 70 ), ( 276, 184, 56 ), ( 276, 207, 42 ), ( 276, 230, 28 ), ( 276, 253, 14 ),

( 299, 0, 182 ), ( 299, 23, 168 ), ( 299, 46, 154 ), ( 299, 69, 140 ), ( 299, 92, 126 ), ( 299, 115, 112 ), ( 299, 138, 98 ), ( 299, 161, 84 ), ( 299, 184, 70 ), ( 299, 207, 56 ), ( 299, 230, 42 ), ( 299, 253, 28 ), ( 299, 276, 14 ),

( 322, 0, 196 ), ( 322, 23, 182 ), ( 322, 46, 168 ), ( 322, 69, 154 ), ( 322, 92, 140 ), ( 322, 115, 126 ), ( 322, 138, 112 ), ( 322, 161, 98 ), ( 322, 184, 84 ), ( 322, 207, 70 ), ( 322, 230, 56 ), ( 322, 253, 42 ), ( 322, 276, 28 ), ( 322, 299, 14 ),

...

}

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)