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

Hello, I have the following setup:

{A,B,C,D,E,F,F#}::Indices(full);
{a,b,c,d,e,f,f#}::Indices(space1);
{m,n,o,p,q,r,r#}::Indices(space2);
\partial{#}::PartialDerivative.
\delta::Accent.
#-------------Fields-----------
F_{A B C}::AntiSymmetric.
F_{a b c}::AntiSymmetric.
F_{m n p}::AntiSymmetric.
F_{#}::Depends(\partial{#}).

Inside the code I have a long integral expression, as an example I will take two terms of this expression, written in latex it is:

$\int dx c_{0} \partial_{a d}\delta F_{a b c}F_{d b c}+2c_{1} \partial_{a c}\delta F_{m a b}F_{m c b}$

Now I want to integrate by parts all objects of the type $\partial_{a b}\delta F$ at once, since there are many such terms using integrate_by_parts on each of them is not desirable.

I tried the following:

integrate_by_parts(_,$\partial_{#}{\delta{F}_{#}}$);

which doesnt change the input at all. I also tried:

integrate_by_parts(_,$\partial_{a??}{\delta{F}_{b?? c?? d??}}$, repeat=True);

which correctly integrates by parts the first term but not the second.

I am new to Cadabra and I dont fully understand how the "?" and "#" operators work. My questions are: Is there some way to achieve my desired outcome? Am I using the "?" and "#" operators incorrectly in this context? In my mind at least one of these lines of code should work, so there must be something I dont understand.

Thank you very much. Stanislav Hronek.

in General questions by

1 Answer

+2 votes

Ah, you found an interesting bug in integrate_by_parts in the code which compares indices with object patterns (e.g. a??) or name patterns (e.g. a?). It's fixed now on github (version 2.3.1.6).

Here's a slight fix of your code, which does the right thing:

{A,B,C,D,E,F,F#}::Indices(full);
{a,b,c,d,e,f,f#}::Indices(space1);
{m,n,o,p,q,r,r#}::Indices(space2);
\partial{#}::PartialDerivative.
\delta{#}::Accent.
F_{A B C}::AntiSymmetric.
F_{a b c}::AntiSymmetric.
F_{m n p}::AntiSymmetric.
F_{#}::Depends(\partial{#}).

ex:=\int{ c_{0} \partial_{a d}{ \delta{F_{a b c}}} F_{d b c}
      + 2 c_{1} \partial_{a c}{ \delta{F_{m a b}}} F_{m c b} }{x};

integrate_by_parts(ex, $\partial_{n?}{\delta{F_{m? a b}}}$)

So to elaborate on those index patterns: There are two ways in which you can write patterns with indices. If you use, in integrate_by_parts, a pattern

\partial_{a}{\delta{F_{m b c}}}

then this will only match a term in which the index on the derivative comes from the space1 set, and the three indices on the F tensor come from space2, space1 and space1 respectively. So in other words, if you write a pattern with indices, then they will match indices from the same set only. As it stands, this pattern would only match your 2nd term (the one multiplying c_{1}).

If you use name patterns, or object patterns, then these will match name or any object. So if you write

\partial_{a}{\delta{F_{m? b c}}}

then this matches both of your terms, because m? can match any name (the fact that it is called m followed by a question mark makes no difference, it does not mean that this object needs to come from the space2 set).

The # pattern means 'any number of child nodes' and is a very generic pattern. Rarely useful inside a substitute or integrate_by_parts because you cannot use it on the right-hand side.

Hope this helps; if not, please ask again.

by (82.5k points)

Thank you very much for the answer, I am sorry for the following trivial question, but how do I update my Cadabra to be the same as the GitHub version?

On which platform are you running this?

linux mint 20 cinnamon.

There's a package for 2.3.1.6 for Mint 20 now on the download pages.

You are the best thank you, I will let you know if the new integrate by parts works for me :)

Yes it works fine now, thank you again.

...