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

I'm trying to simplify a straightforward but tedious expression invovling a product of sums of kronecker deltas. As far as I can tell, the eliminate_kronecker() algorithm likes its input to be completely distributed before it will function properly, and this is where my issue comes in.

For some reason, the distribute() function will distribute most of the terms, but it always leaves one sum left to distribute over, as seen below:

image

Calling distribute() again doesn't change the output. This behavior seems generic, as it also occurs with simpler quantities:

image

I'm new to Cadabra, so I'm probably just doing something simple in the wrong way. Any help would be appreciated.

in General questions by (150 points)
edited by

Hi rtagaras. I'm not sure if others can see the images, but they are broken for me. Is there any possibility you could update/reload the images or add the code (you might use the icon CB to add code blocks).

I've edited the post, try now

Thank you rtagaras!

3 Answers

+1 vote

I can't reproduce this problem; using the input of your simpler second example, distribute does the right thing here.

Which version of Cadabra are you using?

by (82.0k points)

I'm on a fresh install of Version 2.3.9, build 2833.f3ef48635e. Running on Ubuntu.

Before we diagnose this further, can you download 2.4.3.5 (new packages have just been uploaded for most distributions and are available from the download page) and see if that makes the problem go away?

Just installed it, and I'm having the same issue on 2.4.3.5.

+1 vote

Hi rtagaras and Kasper.

Before starting, I'm running cadabra2 v.2.4.3 on Manjaro Linux.

I was able to reproduce the behaviour reported by rtagaras. Let me show some details.

preliminars

I'd use a simplified properties. Note that I'm not defining Greek indices.

{a,b,c,d,m,n,p,q}::Indices.
{a,b,c,d,m,n,p,q}::Integer(range=1..k).
\delta{#}::KroneckerDelta.

A test

ex := \delta^a_a;
eliminate_kronecker(ex);

this code block returns k as expected.

A simple expression

I'd evaluate the second expression reported by rtagaras.

y := X^{a b} X^{c d} ( \delta_{a c} \delta_{b d} + \delta_{a d} \delta_{b c});
distribute(y);

I'm getting the expected result

$$\X^{a b} X^{c d} \delta{a c} \delta{b d}+X^{a b} X^{c d} \delta{a d} \delta{b c}$$

and even better after

eliminate_kronecker(_);

$X{c d} X^{c d}+X{d c} X^{c d}$

No bad behaviour so far.

A more complex manipulation

Now I add some spices

y_new := X^{\mu a} X^{\nu b} X^{\mu m} X^{\nu p}
    ( \delta_{a c} \delta_{b d} + \delta_{a d} \delta_{b c} )
    ( \delta_{m n} \delta_{p q} + \delta_{m q} \delta_{p n} );

distribute(_);

Here I don't get the expected result, but something similar to what rtagaras reports.

For completness:

$X^{\mu a} X^{\nu b} X^{\mu}\,{n} X^{\nu}\,{q}\left(\delta{a c} \delta{b d}+\delta{a d} \delta{b c}\right)+X^{\mu a} X^{\nu b} X^{\mu}\,{q} X^{\nu}\,{n}\left(\delta{a c} \delta{b d}+\delta{a d} \delta{b c}\right)$


Update: Solved by Kasper

I confirm that the addition of the multiplication operation * to the expression solves the unexpected behaviour.

y_new := X^{\mu a} X^{\nu b} X^{\mu m} X^{\nu p} *
    ( \delta_{a c} \delta_{b d} + \delta_{a d} \delta_{b c} ) *
    ( \delta_{m n} \delta_{p q} + \delta_{m q} \delta_{p n} );

distribute(_);
by (14.3k points)
edited by

The problem in your last example is the same as for rtagaras: the whitespace at the end of lines and the beginning of the following is eliminated, and hence your X^{\nu p} at the end of the first line is not multiplied with the bracket on the second line. Rather, it's interpreted as X^{\nu p}( ... ): a tensor with a functional argument given by your first bracket. Adding an explicit product * solves this.

There is a case to be made that newlines and any trailing/leading whitespace should always count as a single space. I might change that.

+2 votes

I think the solution is actually very simple: you are missing a space between the X_{c d} and the opening bracket. This means that Cadabra interprets this as a tensor with argument given by whatever is in the brackets, not as a product of two tensors.

by (82.0k points)

Yep, this solved it. I knew it had to be something simple like that. Thanks!

...