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

I'm confused about how to use the manip.apply_through() function.

The following attempt

ex := A_{\mu \nu} = B_{\mu \nu};

manip.apply_through(ex, \partial_{\rho}{#});

or some variations thereof seem to throw an error. What's the correct way to do this?

in General questions by (740 points)

1 Answer

+1 vote

Hi jsem.

Firstly, I'd recommend that when asking for help you would include a "complete" example of your code (aka minimal working example or MWE), because there are some needed background definitions you are using. Cover that, let's move to your code.

  • The algorithm apply_through is part of a module, cdb.core.manip which has to be imported using import cdb.core.manip as manip.
  • The operator you want to apply has to be surrounded by dollar signs, $\partial_{\rho}{#}$.

That's mainly it!

Let me put it all together in an example

import cdb.core.manip as manip
{\mu,\nu,\rho}::Indices.
D{#}::Derivative.
\partial{#}::PartialDerivative.
{A{#},B{#}}::Depends(\partial{#},D{#}).

# ex := A_{\mu \nu} = B_{\mu \nu};

manip.apply_through($A_{\mu \nu} = B_{\mu \nu}$, $\partial_{\rho}{#}$);

manip.apply_through(ex, $D{#}$);

Hope this would be helpful.

by (14.3k points)

Hi, sorry I should've put in the complete code. I did import the package properly. I think I missed the dollar signs. I thought I tried that, but apparently I hadn't. This works. Thank you.

Great! Nice to hear that.

Cheers.

Actually, I'm still slightly confused about this. Imagine I had two pairs of indices (Greek and lowercase Latin). And I wanted to make two different operations. One is a partial derivative of my tensor w.r.t a Greek index. And as a separate case, I want to take a partial derivative w.r.t the Latin index. I'm unable to get this to work.

The final output of the following code gives me the double derivative \partial_{ b \rho } whereas I'm trying to get only the derivative w.r.t b:

import cdb.core.manip as manip
{\mu,\nu,\rho}::Indices.
{a, b, c}::Indices.

\partial{#}::PartialDerivative.
{A{#},B{#}}::Depends(\partial{#}).

ex := A_{\mu \nu} = B_{\mu \nu};

ex1 = ex

manip.apply_through(ex, $\partial_{\rho}{#}$);

manip.apply_through(ex1, $\partial_{b}{#}$);
...