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

Hi!

I have a problem with the unwrap() function. When I apply it to multiple partial derivatives, it doesn't always work, for example:

{t, x, y, z}::Coordinate.
\partial{#}::PartialDerivative.
a::Depends(t).

unwrap($\partial_{t t x}{a}$);

I was thinking that partial derivatives by definition in Cadabra commute, in which case, unwrap() should give zero.

in Bug reports by (1.4k points)

1 Answer

0 votes

Hi Arina. Great question!

I believe that the mismatch between the expected and actual behaviour of the unwrap algorithm is due to the "phylosophy" of CADABRA, i.e., it is a software centred in manipulation rather than calculation.

The "calculation" component of CADABRA came with the release of version 2.X, through the interaction with PYTHON (in particular with sympy).

Note that if instead of unwrap, you pass your expression to SYMPY, using map_sympy, as follows

map_sympy($\partial_{t}{a}$);

you get the expected result (of executing a calculation).

Hope this can help you!


UPDATE

I understand the point in your comment, hahaha.

It seems to me that unwrap is useful to "move objects out" because they are constant.

Example

In General Relativity the metric is covariantly constant, but its partial derivative is nonvanishing in general. So, you should assign a dependence on the partial derivative but not of the covariant derivative.

{l,m,n}::Indices.
\partial{#}::PartialDerivative.
\nabla{#}::Derivative.
g_{m n}::Depends(\partial{#});
\Psi::Depends(\partial{#},\nabla{#});

Now if you define the derivatives of $g \Psi$, and unwrap, the difference is noticeable.

ex1 := \partial_{l}{ g_{m n} \Psi };
unwrap(ex1);
ex2 := \nabla_{l}{ g_{m n} \Psi };
unwrap(ex2);
by (13.7k points)
edited by

Thanks for your answer! But this still looks weird to me, because if we look in the manual, it says that unwrap() "Move objects out of Derivatives, Accents or exterior (wedge) products when they do not depend on these operators". Therefore, it seems as if the multiple partial derivative does not count as a sequence of operators. I'll try using sympy, but the problem is that I'm working with very large expressions and in practice the Cadabra functions turn out to be noticeably faster and more efficient.

Hi Arina, I've updated my answer in response to your comment. Cheers.

This I understand, I work in both the general covariant and coordinate form. It's just that in these terms, we can say that if a function does not depend on one of the coordinates, then it remains constant when the coordinate is changed. Also, since unwrap() works with accents as well, I think of it as a function that takes variables out from under operators that don't change it. I said that the partial derivatives commute with each other because in my example

unwrap($\partial_{x}{a}$) 

gives 0. So, it is strange to me that adding more partial derivatives does not give this result.

...