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

( 23, 0, 2 ),

( 46, 0, 4 ), ( 46, 23, 2 ),

( 69, 0, 6 ), ( 69, 23, 4 ), ( 69, 46, 2 ),

( 92, 0, 8 ), ( 92, 23, 6 ), ( 92, 46, 4 ), ( 92, 69, 2 ),

( 115, 0, 10 ), ( 115, 23, 8 ), ( 115, 46, 6 ), ( 115, 69, 4 ), ( 115, 92, 2 ),

( 138, 0, 12 ), ( 138, 23, 10 ), ( 138, 46, 8 ), ( 138, 69, 6 ), ( 138, 92, 4 ), ( 138, 115, 2 ),

( 161, 0, 14 ), ( 161, 23, 12 ), ( 161, 46, 10 ), ( 161, 69, 8 ), ( 161, 92, 6 ), ( 161, 115, 4 ), ( 161, 138, 2 ),

( 184, 0, 16 ), ( 184, 23, 14 ), ( 184, 46, 12 ), ( 184, 69, 10 ), ( 184, 92, 8 ), ( 184, 115, 6 ), ( 184, 138, 4 ), ( 184, 161, 2 ),

( 207, 0, 18 ), ( 207, 23, 16 ), ( 207, 46, 14 ), ( 207, 69, 12 ), ( 207, 92, 10 ), ( 207, 115, 8 ), ( 207, 138, 6 ), ( 207, 161, 4 ), ( 207, 184, 2 ),

( 230, 0, 20 ), ( 230, 23, 18 ), ( 230, 46, 16 ), ( 230, 69, 14 ), ( 230, 92, 12 ), ( 230, 115, 10 ), ( 230, 138, 8 ), ( 230, 161, 6 ), ( 230, 184, 4 ), ( 230, 207, 2 ),

( 253, 0, 22 ), ( 253, 23, 20 ), ( 253, 46, 18 ), ( 253, 69, 16 ), ( 253, 92, 14 ), ( 253, 115, 12 ), ( 253, 138, 10 ), ( 253, 161, 8 ), ( 253, 184, 6 ), ( 253, 207, 4 ), ( 253, 230, 2 ),

( 276, 0, 24 ), ( 276, 23, 22 ), ( 276, 46, 20 ), ( 276, 69, 18 ), ( 276, 92, 16 ), ( 276, 115, 14 ), ( 276, 138, 12 ), ( 276, 161, 10 ), ( 276, 184, 8 ), ( 276, 207, 6 ), ( 276, 230, 4 ), ( 276, 253, 2 ),

( 299, 0, 26 ), ( 299, 23, 24 ), ( 299, 46, 22 ), ( 299, 69, 20 ), ( 299, 92, 18 ), ( 299, 115, 16 ), ( 299, 138, 14 ), ( 299, 161, 12 ), ( 299, 184, 10 ), ( 299, 207, 8 ), ( 299, 230, 6 ), ( 299, 253, 4 ), ( 299, 276, 2 ),

( 322, 0, 28 ), ( 322, 23, 26 ), ( 322, 46, 24 ), ( 322, 69, 22 ), ( 322, 92, 20 ), ( 322, 115, 18 ), ( 322, 138, 16 ), ( 322, 161, 14 ), ( 322, 184, 12 ), ( 322, 207, 10 ), ( 322, 230, 8 ), ( 322, 253, 6 ), ( 322, 276, 4 ), ( 322, 299, 2 ),

...

}

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)