Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

In the strict sense of the question i've tried (without having R1):

# def R1(X):   a,b,c = X; return ???
def R2(X):   a,b,c = X; return ( -a, b, c )
def R3(X):   a,b,c = X; return ( -a+2, b, c )
def R4(X):   a,b,c = X; return ( a, -b+2, c )

myFunctions = ( R2, R3, R4, )
myTuples    = [ (0,0,0), ]

depth = 0
while depth < 10:
    depth += 1
    newTuples = []
    for R in myFunctions:
        for X in myTuples:
            RX = R(X)
            if RX not in myTuples and RX not in newTuples:
                newTuples.append( RX )
    myTuples.extend( newTuples )
    print "There are %s tuples after a generation of depth %s" % ( len(myTuples), depth )

And we get:

There are 3 tuples after a generation of depth 1
There are 5 tuples after a generation of depth 2
There are 7 tuples after a generation of depth 3
There are 9 tuples after a generation of depth 4
There are 11 tuples after a generation of depth 5
There are 13 tuples after a generation of depth 6
There are 15 tuples after a generation of depth 7
There are 17 tuples after a generation of depth 8
There are 19 tuples after a generation of depth 9
There are 21 tuples after a generation of depth 10

and the list (and the mark points 3,5,7,...) show which tuples were added at each step. (It was simpler for me to use tuples.)

A better idea would be (for my taste) to introduce a fourth component equal to one and to use matrix multiplication for the above operations using the matrices from the following code:

v  = matrix( QQ, 4, 1, [0,0,0,1] )
R2 = matrix.diagonal( QQ, [-1,1,1,1] )
R3 = matrix.elementary( QQ, 4, row1=0, row2=3, scale=2 ) * R2
R4 = matrix.elementary( QQ, 4, row1=1, row2=3, scale=2 ) * matrix.diagonal( QQ, [1,-1,1,1] )

print "R2 is\n%s\n" % R2
print "R3 is\n%s\n" % R3
print "R4 is\n%s\n" % R4

print "R2 * v transposed is %s" % ( R2*v ).transpose()
print "R3 * v transposed is %s" % ( R3*v ).transpose()
print "R4 * v transposed is %s" % ( R4*v ).transpose()

where i had more to print the following matrices than to define them.

R2 is
[-1  0  0  0]
[ 0  1  0  0]
[ 0  0  1  0]
[ 0  0  0  1]

R3 is
[-1  0  0  2]
[ 0  1  0  0]
[ 0  0  1  0]
[ 0  0  0  1]

R4 is
[ 1  0  0  0]
[ 0 -1  0  2]
[ 0  0  1  0]
[ 0  0  0  1]

R2 * v transposed is [0 0 0 1]
R3 * v transposed is [2 0 0 1]
R4 * v transposed is [0 2 0 1]