Welcome to Cadabra Q&A, where you can ask questions and receive answers from other members of the community.
0 votes

every time I am running collectfactors(); it shows kernel crashed and restarted and I have to run all the cells from the beginning.

in Bug reports by (170 points)
edited by

You need to make this a bit more specific; can you provide a minimal example that shows the crash?

for example i have a term like ex:Y{a b}=2^{1/2}\psi 2^{1/2}k{a} k_{b}; and after that I entered collectfactors(); then a new window appears notifying "kernel crashed unexpectedly, and has been restarted. You will need to re-run all cells".

If I enter in an empty notebook

ex:= Y_{a b}=2^{1/2}\psi 2^{1/2}k_{a} k_{b};

it does not crash, so your case probably contains more code. Can you give a complete and minimal example that shows the crash?

Note that 2^{1/2} is not 'two to the power one half'. Write that as 2**{1/2}.

If I have the following definition Q2:=Q2{a b}= k{a} k{b} ex:Y{a b}=2^{1/2}\psi 2^{1/2}Q2{a b}; does this affect the result because there is a numerical factor combined with Q?

I just ran this much in a new kernel and still have the same problem:

ex:=k^{a}n_{c a}+2**{1/2} k_{c} 2**{1/2};

Ok, I see what is going wrong. As a temporary workaround, can you do

map_sympy(_, "simplify");

instead of collect_terms. That will take care of the simplification of the square roots as well. I'll post here when the bug is fixed.

yeah, thanks!!!

So I was working with the temporary code

map_sympy(_, "simplify");

It worked for expression like

ex:=k^{a}n_{c a}+2**{1/2} k_{c} 2**{1/2};

However when I had to simplify an expression having terms like

ex:= Y^{a}_{b c d}=F^{a}_{b c d}+2**{1/2}\psi 2**{1/2}k^{a} Q1_{b c d}+ l^{a} Q2_{b c d};
map_sympy(_, "simplify");

then it resulted in the following error.

TokenError: ('EOF in multi-line statement',(2, 0)) At : /usr/lib/python3/dist-packages/sympy/parsing/sympy_tokenize.py(384) : generate_tokens

One more thing I noticed is that substituting \psi with some letter say p did the work.

1 Answer

0 votes

You probably either did not terminate an expression line with ; or :, or you tried to wrap a Cadabra expression over multiple lines by using \. If it's the latter, just remove that \; Cadabra expressions can wrap over multiple lines without Python's line continuation character.

by (66.3k points)