The rational number 45/16 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.

45/16 = (45-0)/16 = {

( 45, 0, 16 ),

( 90, 0, 32 ), ( 90, 45, 16 ),

( 135, 0, 48 ), ( 135, 45, 32 ), ( 135, 90, 16 ),

( 180, 0, 64 ), ( 180, 45, 48 ), ( 180, 90, 32 ), ( 180, 135, 16 ),

( 225, 0, 80 ), ( 225, 45, 64 ), ( 225, 90, 48 ), ( 225, 135, 32 ), ( 225, 180, 16 ),

( 270, 0, 96 ), ( 270, 45, 80 ), ( 270, 90, 64 ), ( 270, 135, 48 ), ( 270, 180, 32 ), ( 270, 225, 16 ),

( 315, 0, 112 ), ( 315, 45, 96 ), ( 315, 90, 80 ), ( 315, 135, 64 ), ( 315, 180, 48 ), ( 315, 225, 32 ), ( 315, 270, 16 ),

( 360, 0, 128 ), ( 360, 45, 112 ), ( 360, 90, 96 ), ( 360, 135, 80 ), ( 360, 180, 64 ), ( 360, 225, 48 ), ( 360, 270, 32 ), ( 360, 315, 16 ),

( 405, 0, 144 ), ( 405, 45, 128 ), ( 405, 90, 112 ), ( 405, 135, 96 ), ( 405, 180, 80 ), ( 405, 225, 64 ), ( 405, 270, 48 ), ( 405, 315, 32 ), ( 405, 360, 16 ),

( 450, 0, 160 ), ( 450, 45, 144 ), ( 450, 90, 128 ), ( 450, 135, 112 ), ( 450, 180, 96 ), ( 450, 225, 80 ), ( 450, 270, 64 ), ( 450, 315, 48 ), ( 450, 360, 32 ), ( 450, 405, 16 ),

( 495, 0, 176 ), ( 495, 45, 160 ), ( 495, 90, 144 ), ( 495, 135, 128 ), ( 495, 180, 112 ), ( 495, 225, 96 ), ( 495, 270, 80 ), ( 495, 315, 64 ), ( 495, 360, 48 ), ( 495, 405, 32 ), ( 495, 450, 16 ),

( 540, 0, 192 ), ( 540, 45, 176 ), ( 540, 90, 160 ), ( 540, 135, 144 ), ( 540, 180, 128 ), ( 540, 225, 112 ), ( 540, 270, 96 ), ( 540, 315, 80 ), ( 540, 360, 64 ), ( 540, 405, 48 ), ( 540, 450, 32 ), ( 540, 495, 16 ),

( 585, 0, 208 ), ( 585, 45, 192 ), ( 585, 90, 176 ), ( 585, 135, 160 ), ( 585, 180, 144 ), ( 585, 225, 128 ), ( 585, 270, 112 ), ( 585, 315, 96 ), ( 585, 360, 80 ), ( 585, 405, 64 ), ( 585, 450, 48 ), ( 585, 495, 32 ), ( 585, 540, 16 ),

( 630, 0, 224 ), ( 630, 45, 208 ), ( 630, 90, 192 ), ( 630, 135, 176 ), ( 630, 180, 160 ), ( 630, 225, 144 ), ( 630, 270, 128 ), ( 630, 315, 112 ), ( 630, 360, 96 ), ( 630, 405, 80 ), ( 630, 450, 64 ), ( 630, 495, 48 ), ( 630, 540, 32 ), ( 630, 585, 16 ),

...

}

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)