2
$\begingroup$

I want to perform simple calculations involving kronecker deltas without specifying the dimension of the space I am in.

For example, I would like to automatically calculate (note the implied Einstein summation convention): $$\delta_{i,j}\delta_{j,k}=\delta_{i,k}$$ and $$\delta_{i,i}=d$$ This is straightforward to do by hand, but the expressions involved are lengthy, so this is tediuous: e.g. I want to evaluate expressions sort of like the following, but a bit more complicated: $$(\delta_{a,b}\delta_{c,d} \delta_{e,f}+3\delta_{a,d}\delta_{c,f} \delta_{e,b})(\delta_{i,j}\delta_{c,d} \delta_{e,f}+3\delta_{i,d}\delta_{c,f} \delta_{e,j})=?$$

I would think this is easy to do, but I cannot figure out how.

$\endgroup$
3
$\begingroup$

You can use the new in M10 Tensor* function to do this, although it is a bit long-winded. First, lets define your identity matrix:

id = IdentityMatrix[d];

Next, we can represent your individual terms using TensorProduct and TensorTranspose. For example,

$\delta _{a,b} \delta _{c,d} \delta _{e,f}$:

TensorProduct[id, id, id];

$\delta _{a,d} \delta _{e,b} \delta _{c,f}$:

TensorTranspose[TensorProduct[id, id, id], {1, 4, 3, 6, 5, 2}];

and similarly for the others. Finally, we want to contract the expression:

res = TensorContract[
    TensorProduct[
        (
        TensorProduct[id, id, id] + 
        3 TensorTranspose[TensorProduct[id, id, id], {1, 4, 3, 6, 5, 2}]
        ),
        (
        TensorProduct[id, id, id] +
        3 TensorTranspose[TensorProduct[id, id, id], {1, 4, 3, 6, 5, 2}]
        )
    ],
    {{3, 9}, {4, 10}, {5, 11}, {6, 12}}
];

Unfortunately, TensorReduce is not able to simplify this further. However, we can make use of my TensorSimplify package to help out. Install the paclet with::

PacletInstall[
    "TensorSimplify",
    "Site"->"http://raw.githubusercontent.com/carlwoll/TensorSimplify/master"
]

and then load the package with:

<<TensorSimplify`

Then:

TensorSimplify[res]

6 IdentityMatrix[d]\[TensorProduct]IdentityMatrix[d] + d^2 IdentityMatrix[d]\[TensorProduct]IdentityMatrix[d] + 9 d TensorTranspose[ IdentityMatrix[d]\[TensorProduct]IdentityMatrix[d], {1, 3, 2, 4}]

In terms of kronecker deltas, the above is equivalent to:

$$d^2 \delta _{a,b} \delta _{i,j}+9 d \delta _{a,i} \delta _{b,j}+6 \delta_{a,b} \delta _{i,j}$$

$\endgroup$
  • $\begingroup$ excellent answer and a very useful package. Can I ask how you got from the Mathematica expression of the TensorSimplify command to restoring the subscripts in Kronecker deltas? I see the {1,3,24} in the end which indicates the ordering of the term proportional to 9d, but the other expressions are blank. Thanks $\endgroup$ – A_user_with_NoName Mar 27 '18 at 9:34
  • $\begingroup$ Thanks. The non-trivial part appears to be your package, which seems the most important. I was previously trying to do something involving replacement rules acting on symbolic expressions. But I think this will work. $\endgroup$ – simple_Guest Mar 27 '18 at 14:25
  • 1
    $\begingroup$ @Konstantinos For a rank 4 tensor T, TensorTranspose[T, {1, 2, 3, 4}] is equivalent to T. So, imagine that there is a TensorTranspose wrapper on the other terms. $\endgroup$ – Carl Woll Mar 27 '18 at 16:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.