The rational number 48/31 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.

48/31 = (48-0)/31 = {

( 48, 0, 31 ),

( 96, 0, 62 ), ( 96, 48, 31 ),

( 144, 0, 93 ), ( 144, 48, 62 ), ( 144, 96, 31 ),

( 192, 0, 124 ), ( 192, 48, 93 ), ( 192, 96, 62 ), ( 192, 144, 31 ),

( 240, 0, 155 ), ( 240, 48, 124 ), ( 240, 96, 93 ), ( 240, 144, 62 ), ( 240, 192, 31 ),

( 288, 0, 186 ), ( 288, 48, 155 ), ( 288, 96, 124 ), ( 288, 144, 93 ), ( 288, 192, 62 ), ( 288, 240, 31 ),

( 336, 0, 217 ), ( 336, 48, 186 ), ( 336, 96, 155 ), ( 336, 144, 124 ), ( 336, 192, 93 ), ( 336, 240, 62 ), ( 336, 288, 31 ),

( 384, 0, 248 ), ( 384, 48, 217 ), ( 384, 96, 186 ), ( 384, 144, 155 ), ( 384, 192, 124 ), ( 384, 240, 93 ), ( 384, 288, 62 ), ( 384, 336, 31 ),

( 432, 0, 279 ), ( 432, 48, 248 ), ( 432, 96, 217 ), ( 432, 144, 186 ), ( 432, 192, 155 ), ( 432, 240, 124 ), ( 432, 288, 93 ), ( 432, 336, 62 ), ( 432, 384, 31 ),

( 480, 0, 310 ), ( 480, 48, 279 ), ( 480, 96, 248 ), ( 480, 144, 217 ), ( 480, 192, 186 ), ( 480, 240, 155 ), ( 480, 288, 124 ), ( 480, 336, 93 ), ( 480, 384, 62 ), ( 480, 432, 31 ),

( 528, 0, 341 ), ( 528, 48, 310 ), ( 528, 96, 279 ), ( 528, 144, 248 ), ( 528, 192, 217 ), ( 528, 240, 186 ), ( 528, 288, 155 ), ( 528, 336, 124 ), ( 528, 384, 93 ), ( 528, 432, 62 ), ( 528, 480, 31 ),

( 576, 0, 372 ), ( 576, 48, 341 ), ( 576, 96, 310 ), ( 576, 144, 279 ), ( 576, 192, 248 ), ( 576, 240, 217 ), ( 576, 288, 186 ), ( 576, 336, 155 ), ( 576, 384, 124 ), ( 576, 432, 93 ), ( 576, 480, 62 ), ( 576, 528, 31 ),

( 624, 0, 403 ), ( 624, 48, 372 ), ( 624, 96, 341 ), ( 624, 144, 310 ), ( 624, 192, 279 ), ( 624, 240, 248 ), ( 624, 288, 217 ), ( 624, 336, 186 ), ( 624, 384, 155 ), ( 624, 432, 124 ), ( 624, 480, 93 ), ( 624, 528, 62 ), ( 624, 576, 31 ),

( 672, 0, 434 ), ( 672, 48, 403 ), ( 672, 96, 372 ), ( 672, 144, 341 ), ( 672, 192, 310 ), ( 672, 240, 279 ), ( 672, 288, 248 ), ( 672, 336, 217 ), ( 672, 384, 186 ), ( 672, 432, 155 ), ( 672, 480, 124 ), ( 672, 528, 93 ), ( 672, 576, 62 ), ( 672, 624, 31 ),

...

}

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)