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

( 23, 0, 8 ),

( 46, 0, 16 ), ( 46, 23, 8 ),

( 69, 0, 24 ), ( 69, 23, 16 ), ( 69, 46, 8 ),

( 92, 0, 32 ), ( 92, 23, 24 ), ( 92, 46, 16 ), ( 92, 69, 8 ),

( 115, 0, 40 ), ( 115, 23, 32 ), ( 115, 46, 24 ), ( 115, 69, 16 ), ( 115, 92, 8 ),

( 138, 0, 48 ), ( 138, 23, 40 ), ( 138, 46, 32 ), ( 138, 69, 24 ), ( 138, 92, 16 ), ( 138, 115, 8 ),

( 161, 0, 56 ), ( 161, 23, 48 ), ( 161, 46, 40 ), ( 161, 69, 32 ), ( 161, 92, 24 ), ( 161, 115, 16 ), ( 161, 138, 8 ),

( 184, 0, 64 ), ( 184, 23, 56 ), ( 184, 46, 48 ), ( 184, 69, 40 ), ( 184, 92, 32 ), ( 184, 115, 24 ), ( 184, 138, 16 ), ( 184, 161, 8 ),

( 207, 0, 72 ), ( 207, 23, 64 ), ( 207, 46, 56 ), ( 207, 69, 48 ), ( 207, 92, 40 ), ( 207, 115, 32 ), ( 207, 138, 24 ), ( 207, 161, 16 ), ( 207, 184, 8 ),

( 230, 0, 80 ), ( 230, 23, 72 ), ( 230, 46, 64 ), ( 230, 69, 56 ), ( 230, 92, 48 ), ( 230, 115, 40 ), ( 230, 138, 32 ), ( 230, 161, 24 ), ( 230, 184, 16 ), ( 230, 207, 8 ),

( 253, 0, 88 ), ( 253, 23, 80 ), ( 253, 46, 72 ), ( 253, 69, 64 ), ( 253, 92, 56 ), ( 253, 115, 48 ), ( 253, 138, 40 ), ( 253, 161, 32 ), ( 253, 184, 24 ), ( 253, 207, 16 ), ( 253, 230, 8 ),

( 276, 0, 96 ), ( 276, 23, 88 ), ( 276, 46, 80 ), ( 276, 69, 72 ), ( 276, 92, 64 ), ( 276, 115, 56 ), ( 276, 138, 48 ), ( 276, 161, 40 ), ( 276, 184, 32 ), ( 276, 207, 24 ), ( 276, 230, 16 ), ( 276, 253, 8 ),

( 299, 0, 104 ), ( 299, 23, 96 ), ( 299, 46, 88 ), ( 299, 69, 80 ), ( 299, 92, 72 ), ( 299, 115, 64 ), ( 299, 138, 56 ), ( 299, 161, 48 ), ( 299, 184, 40 ), ( 299, 207, 32 ), ( 299, 230, 24 ), ( 299, 253, 16 ), ( 299, 276, 8 ),

( 322, 0, 112 ), ( 322, 23, 104 ), ( 322, 46, 96 ), ( 322, 69, 88 ), ( 322, 92, 80 ), ( 322, 115, 72 ), ( 322, 138, 64 ), ( 322, 161, 56 ), ( 322, 184, 48 ), ( 322, 207, 40 ), ( 322, 230, 32 ), ( 322, 253, 24 ), ( 322, 276, 16 ), ( 322, 299, 8 ),

...

}

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)