Ask Your Question
1

Recursive calculation of a characteristic polynomial

asked 2020-04-20 00:06:55 +0100

Erratis gravatar image

updated 2020-04-20 15:07:19 +0100

slelievre gravatar image

I am trying to calculate the characteristic polynomial of a complex arrangement of dimension 3 using recursion. But I am getting a return that doesn't make any sense to me. The code looks like this:

def threeDimChaPol(Matroid):
    if Matroid.rank() <= 2:
        MatGS = len(Matroid.groundset_list()) - 1
        return x * (x - MatGS) * (x - 1)
    HE = Matroid.groundset_list()[-1]
    print HE
    MatD = Matroid.delete(HE)
    MatR = Matroid.contract(HE).simplify()
    R = len(MatR.groundset_list()) - 1
    return threeDimChaPol(MatD) - (x - 1) * (x - R)

I am feeding the function with the Matroid that comes out when I use the normalvectors of the hyperplanes of the G32 and trim it down to 4 specific hyperplanes.

I use Matroid(Matrix(NF3, G32Normals).transpose()), where I prepared a list of the G32 normalvectors in which I use a numberfield instead of a cyclotomic field for the complex numbers (the vectors are in the same order as when you get them through ReflectionGroups). I then use deletion on everything, but 0,1,2,12 and get a Matroid of rank 4 with 4 elements.

If I now use the function above it responds 12,2 as it should, because they are the things chosen out of the groundset, but instead of returning the polynomial it just writes 53466 after that.

So the return is just a number, which does not make any sense to me. Before I wrote this into a new file, double attaching the file, where this function is in, to sage solved the problem and gave the right result. When I restarted sage and attached in only once the bug would appear again. But writing the function alone with the neccessary information (Matroid and Vectors) into a new file and attaching it just gives me the 53466 return, no matter how often I attach it to sage.

Since the code is working sometimes and other times not it really confuses me where the mistake could be. Any kind of help would be greatly appreciated!

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
4

answered 2020-04-20 08:55:38 +0100

FrédéricC gravatar image

what is x ? Do you define x somewhere else ? add x = polygen(QQ,'x') to your function

edit flag offensive delete link more

Comments

Thanks for your reply. I'm sorry, but I forgot to mention that x = polygen(QQ,'x') already exists at the beginning of the program. The idea is that I don't have to define it again in that function (it saves runtime). Do you think that this could cause the bug? I will just write the polygen back into the function then.

The strange thing is that it seems to work in most cases. It goes wrong sometimes when the polynomial factors with 3 ones and 1 zero.

Update: It instantly seems to work now. Does that have to do anything with how python operates? I am pretty new to this so I thought that defining it global would be a good idea. I will try do do a bigger calculation and look if the bug keeps appearing. Thanks for your help!

Erratis gravatar imageErratis ( 2020-04-20 16:56:35 +0100 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2020-04-20 00:06:55 +0100

Seen: 863 times

Last updated: Apr 20 '20