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

I found this bug in Cadabra 1.x, but it remains in Cadabra 2.2.1.

It is likely related to a prior bug I found: https://cadabra.science/qa/761/bug-in-%40unwrap-for-cadabra-1-42 but I list it here because the failure behavior is interesting!

In Cadabra 2 syntax:


Now the following returns 0 (!).

Exp := \partial{(A F + G) C};

I expect the issue is that there is no easy way to push C past (A F + G) because the relative sign between A F and G would flip. Instead if one distributes or applies product rule prior to unwrapping, the result returns as expected.

The following, however, does work as expected:

Exp := \partial{(A F + B G) C};

giving Exp = - C * \partial{A F + B G}.

in Bug reports by (1.0k points)

1 Answer

0 votes

Good one. Internally, when Cadabra cannot figure out how to commute two objects, an internal function somewhere returns '0', instead of '+1' or '-1'. That zero should have made unwrap stop, but instead it just went ahead and then multiplied the resulting unwrapped expression with '0'.

Now fixed in github, can you give it a shot? It will leave that first expression untouched, because it cannot move C through A F + G without flipping that 2nd factor to A F - G, and it will not do that kind of thing. Hope that's ok for now.

by (82.0k points)

Let me also have a quick look at that other bug (which completely went off my radar), hang on.

The other one's fixed now too. There are still issues with taking out factors with anti-commute with the index wrt. which the derivative is taken, beware.

OK, thanks, Kasper! I'll play with it soon and let you know. (I will have to port some code over to v2.)