Ask Your Question

SarahDi's profile - activity

2022-09-04 11:47:27 +0200 received badge  Famous Question (source)
2022-02-07 12:03:21 +0200 received badge  Notable Question (source)
2022-02-07 12:03:21 +0200 received badge  Popular Question (source)
2020-09-24 18:13:02 +0200 asked a question Anyone who has computing power and can run some code for me?

Hello, I am running the following code (which should be correct because it works and gives results when applied to E7, E6, up to a couple of modification, A6 and A5 for instance), and on my laptop it takes ages, and actually has not even started to compute the first 5000 cases. Can anyone just help me by running it on some more powerful computer? Is there any other website where I could ask for this kind of help? :

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))
a7 = vector((0, 0, 0, 0, -1, 1, 0, 0))
a8 = vector((0, 0, 0, 0, 0, -1, 1, 0))

def proj(t, ai):
     myLone = vector(ai)
     result= t - myLone.dot_product(t) / (ai.dot_product(ai))*myLone
     return result


  # produce all combinaisons in myL of five vectors, and apply the procedure to them: the procedure consists in writing
  # the Weyl group associated to any five elements in myL (call any myLel)

def gensi(t, projai):
   myLone = projai
   result = t- 2*myLone.dot_product(t)/(projai.dot_product(projai))*myLone
   return result

 def decompose(g, mylength):
# g is a str(aa) where aa belongs to list(WeylGroup ...)
      listg = [g[3*i]+ g[3*i+1] for i in range(0, mylength)]
      return listg

def letsapply(listg, alist, p1, p2, p3, p4, p5, p6, p7):
      mylistg = listg
      mylistg.reverse()
      for si in mylistg:
    if si == 's1':
        alist = map(lambda w: gensi(w, p1), alist)
    elif si == 's2':
        alist = map(lambda w: gensi(w, p2), alist)
    elif si == 's3':
        alist = map(lambda w: gensi(w, p3), alist)
    elif si == 's4':
        alist = map(lambda w: gensi(w, p4), alist)
    elif si == 's5':
        alist = map(lambda w: gensi(w, p5), alist)
    elif si == 's6':
        alist = map(lambda w: gensi(w, p6), alist)
    elif si == 's7':
        alist = map(lambda w: gensi(w, p7), alist)   
    else:
        print("Wrong input in letsapply!!")
alistt = [tuple(v) for v in alist]
alistts = set(alistt)

return alistts


  import sys
  from timeit import default_timer as timer

 def main():
  starttime = timer()
 W = WeylGroup(["A", 7], prefix="s")
  listW = list(W)
  # We remove the first element which is 1:
  listW.pop(0)
  listWdecomposed = [decompose(str(g), g.length()) for g in listW]

 e = RootSystem(['E',8]).ambient_space()
Roots = e.roots()
## get all projections of roots in E6
myR = [vector(v) for v in Roots]
myL = [proj(x, a2) for x in myR]
myL = [pp for pp in myL if pp != zero_vector(8)]
print("myL = ", myL)
print("myL has ", len(myL), " components.") 

print(len(Combinations(myL, 7).list()))
print("End of precomputations, beginning of the loop.")
WhenToTell = 5000 # Every WhenToTell, the program writes something
CounterToTell = 0
for myLel in Combinations(myL, 7):
    #print("Next element of myLlist ...")
    [proja1, proja2, proja3, proja4, proja5, proja6, proja7] = myLel
    res = set(tuple(v) for v in myLel)
    CounterToTell += 1 # We add 1
    ShouldTakeNextmyLel = False
    ### NONONO print("Trying ", myLel)
    for listg in listWdecomposed:
        res = res.union(letsapply(listg, myLel, proja1, proja2, proja3, proja4, proja5, proja6, proja7))
        #sys.stdout.write(".")# That's print without a return
        if len(res) > 56:
            ShouldTakeNextmyLel = True
            break # No use continuing with this myLel
    if ShouldTakeNextmyLel:
        next
    # On reconvertit :
    res = [vector(v) for v in res]
    res = list(res)
    #print("End")

    if len(res) == 56:    
        LLL =[]
        lst=[]
        for a in myLel:
            for b in myLel:
                R = a.dot_product(b)
                lst.append(R)
            #print(a, lst, "lst") 
            if  (lst.count(-1)==1 or lst.count(-1)==2) and lst.count(1)==0 and lst.count(2) ==1 and (lst.count(0)==4 or lst.count(0)==5):
                LLL.append(lst)
                lst=[]
            else:
                break 

        if len(LLL) ==7: 
            print("myLel = ", myLel)
            print("res = ", res)
            print(LLL, "LLL") 
        #else:
        #print("not the basis of root system")
        #break # Exceptional exit from "for" loop
    #else:
     #   print("too many vectors in this subspace")
    ## Give some info on the running:
    if CounterToTell%WhenToTell == 0:
        endtime = timer()
        print("We used ", endtime - starttime, " seconds for ", WhenToTell, " cases.")
        starttime = endtime
return 0
main()
2020-09-10 17:25:00 +0200 asked a question checking a list of vectors constitute the basis of a root system

In this area of Sage link text is there a command to check a set of vectors satisfy the conditions to be a basis of a root system?

2020-08-25 11:51:27 +0200 commented answer Root systems algorithm: "TypeError: 'str' object is not callable"

Cool. Merci :)

2020-08-20 09:51:44 +0200 commented answer Root systems algorithm: "TypeError: 'str' object is not callable"

This code along with the main function below work fine:

def main():
    W = WeylGroup(["A", 5], prefix="s")
    listW = list(W)
    # We remove the first element which is 1:
    listW.pop(0)
    listWdecomposed = [decompose(str(g), g.length()) for g in listW]
    res = set(tuple(v) for v in myP)

    for listg in listWdecomposed:
        res = res.union(letsapply(listg, myP))

    # On reconvertit :
    res = [vector(v) for v in res]
    res.sort()
    return(len(res), res)

Now, I am trying to do a loop where I apply this function 'main' to the list of all sets of five random vectors in myL, this is why I have added the p1,p2... in the letsapply function.

2020-08-20 09:45:08 +0200 commented answer Root systems algorithm: "TypeError: 'str' object is not callable"

Hi, the si applied is the si defined here:

myP = [proj(x, a6) for x in Lini]
 [proja1, proja2, proja3, proja4, proja5] = myP
    def si(t, projai):
            myLone = projai
            result = t- 2*myLone.dot_product(t)/(projai.dot_product(projai))*myLone
            return result
2020-08-19 22:54:59 +0200 asked a question Root systems algorithm: "TypeError: 'str' object is not callable"

I am rather new to Sage and formal language.

I am running the following code which works fine with a slighty simpler version (where the variables p1, p2, ..., p5 in the function letsapply are fixed).

Here is the original function that works fine:

def letsapply(listg, alist):
    mylistg = listg
    mylistg.reverse()
    for si in mylistg:
        if si == 's1':
            alist = map(s1, alist)
        elif si == 's2':
            alist = map(s2, alist)
        elif si == 's3':
            alist = map(s3, alist)
        elif si == 's4':
            alist = map(s4, alist)
        elif si == 's5':
            alist = map(s5, alist)
        elif si == 's6':
            alist = map(s6, alist)
        else:
            print("Wrong input in letsapply!!")
    alistt = [tuple(v) for v in alist]
    alistts = set(alistt)
    return alistts

Below, I am getting the following

TypeError: 'str' object is not callable

Could anyone help me fix this? Thanks a lot!

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]

# alist is the set of all projections of roots in E6

myR = [vector(v) for v in Roots]

def proj(t, ai):
    myLone = vector(ai)
    result= t - myLone.dot_product(t) / (ai.dot_product(ai))*myLone
    return result

myL = [proj(x, a6) for x in myR]

def si(t, projai):
      myLone = projai
      result = t- 2*myLone.dot_product(t)/(projai.dot_product(projai))*myLone
      return result

def decompose(g, mylength):
    # g is a str(aa) where aa belongs to list(WeylGroup ...)
    listg = [g[3*i]+ g[3*i+1] for i in range(0, mylength)]
    return listg

def letsapply(listg, alist, p1, p2, p3, p4, p5):
    mylistg = listg
    mylistg.reverse()
    for si in mylistg:
        if si == 's1':
            alist = map(lambda w: si(w, p1), alist)
        elif si == 's2':
            alist = map(lambda w: si(w, p2), alist)
        elif si == 's3':
            alist = map(lambda w: si(w, p3), alist)
        elif si == 's4':
            alist = map(lambda w: si(w, p4), alist)
        elif si == 's5':
            alist = map(lambda w: si(w, p5), alist)
        else:
            print("Wrong input in letsapply!!")
    alistt = [tuple(v) for v in alist]
    alistts = set(alistt)
    return alistts

def main():
    W = WeylGroup(["A", 5], prefix="s")
    listW = list(W)
    # We remove the first element which is 1:
    listW.pop(0)
    listWdecomposed = [decompose(str(g), g.length()) for g in listW]

    e = RootSystem(['E',6]).ambient_space()
    Roots = e.roots()
    ## get all projections of roots in E6
    myR = [vector(v) for v in Roots]
    myL = [proj(x, a6) for x in myR]
    print("myL =", myL)

    # produce all combinaisons in myL of five vectors,
    # and apply the procedure to them: the procedure consists first in writing
    # the Weyl group associated to any five elements in myL (call any : myLel),
    # then applying these elements si to myLel

    myLlist= Combinations(myL, 5).list()
    for myLel in myLlist:
        [proja1, proja2, proja3, proja4, proja5] = myLel
    res = set(tuple(v) for v in myLel)
    for listg in listWdecomposed:
        res = res.union(letsapply(listg, myLel, proja1, proja2, proja3, proja4, proja5))
        # Reconvert
        res = [vector(v) for v in res]
        res.sort()
    if len(res)< 30:
        return(len(res), res)
    else:
        print("too many vectors in this subspace")
    return 0
    main()
2020-08-19 20:31:16 +0200 commented answer An algorithm on root systems' vectors "ValueError: too many values to unpack "

Yes, my bad, I wanted :

if len(myLset1) >= 5: [proja1, proja2, proja3, proja4, proja5] = myLset1 Thanks!

2020-08-19 20:29:01 +0200 received badge  Supporter (source)
2020-08-19 20:12:37 +0200 received badge  Editor (source)
2020-08-19 16:00:59 +0200 received badge  Student (source)
2020-08-19 15:49:27 +0200 asked a question 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))