An algorithm on root systems' vectors "ValueError: too many values to unpack "
While finishing a math project, I need to run the following code, and get an error message which seems related to Sage calculation capacity, could anyone help me through this? (I am quite new to Sage.) If there is no way to handle that in Sage, could anyone recommend me another software with similar language where this code could be run properly?
e = RootSystem(['E', 6]).ambient_space()
Roots = e.roots()
a1 = vector((1/2, -1/2, -1/2, -1/2, -1/2, -1/2, -1/2, 1/2))
a2 = vector((1, 1, 0, 0, 0, 0, 0, 0))
a3 = vector((-1, 1, 0, 0, 0, 0, 0, 0))
a4 = vector((0, -1, 1, 0, 0, 0, 0, 0))
a5 = vector((0, 0, -1, 1, 0, 0, 0, 0))
a6 = vector((0, 0, 0, -1, 1, 0, 0, 0))
Lini = [a1, a2, a3, a4, a5]
def proj(t, ai):
myLone = vector(ai)
result= t - myLone.dot_product(t) / (ai.dot_product(ai))*myLone
return result
myP = [proj(x, a6) for x in Lini]
[proja1, proja2, proja3, proja4, proja5] = myP
myR = [vector(v) for v in Roots]
myL = [proj(x, a6) for x in myR]
len(myL)
myPlist1= Combinations(myP, 3).list()
myLlist1= Combinations(myL, 2).list()
# alternatively: produce all combinaisons in myL of five vectors
# (all to be used in a function where these combinaisons are variables:
# this does not work either
# myLlist = Combinations(myL, 5).list()
def letsapply(listg, alist):
for listel in listg:
myPset1= set(tuple(v) for v in listel)
print(myPset1)
for listel2 in alist:
myLset1 = set(tuple(v) for v in listel2)
print(myLset1)
myLset1 = myLset1.union(myPset1)
if len(myLset1) >= 5:
print(myLset1, "myLset1")
if len(myLset1) >= 5:
for myLel in myLset1:
[proja1, proja2, proja3, proja4, proja5] = myLel
print(myLel)
print(letsapply(myPlist1, myLlist1))
Beware about the indentation. If you need nested loops, you should indent the inner loop more than the outer loop.