4

I have a really simple problem but I don't know how to solve it. Basically, I am doing vecor manipulation and I am summing a lot of Kronecker delta here and there. How can I teach Mathematica that for any sum of the form $ \sum_{i=1}^{d}\delta_{\mu\nu}\delta_{\mu\nu}=d $. I tried

$Assumptions = Sum[KroneckerDelta[μ, ν] KroneckerDelta[μ, ν], {u, 1,
 d}, {μ, 1, d}] == d

Which does not work. To be precise, consider a Ansatz of the following form, depending on a vector $\vec{s}$ and some coefficients.

customAnsatzC[s_, μ_, ν_, λ_, σ_] := C1 s.s KroneckerDelta[μ, ν] KroneckerDelta[λ, σ] + 
C2 s.s (KroneckerDelta[μ, σ] KroneckerDelta[λ, ν] + 
KroneckerDelta[μ, λ]KroneckerDelta[ν, σ]);

When I take the Trace of something like this, it gives back

Sum[KroneckerDelta[μ, ν] KroneckerDelta[λ, σ] customAnsatzC[{s1, s2, s3, 
 s4}, μ, ν, λ, σ], {λ, 1, 4}, {σ, 1, 4}, {μ, 1, 4}, {ν, 1, 4}] // FullSimplify

This gives back $8 (2 C1 + C2) (s1^2 + s2^2 + s3^2 + s4^2)$ but I would like it to give back $(d^2C1 + 2dC2)(s1^2+s2^2+s3^2+s4^2)$ instead. Is there a way to do this ?

Carl Woll
  • 130,679
  • 6
  • 243
  • 355
Ezareth
  • 379
  • 1
  • 9

1 Answers1

9

You could just do:

Sum[KroneckerDelta[μ, ν] KroneckerDelta[μ, ν], {ν, d}, {μ, d}, Assumptions->d>1]

d

Although it might make sense to use symbolic tensors instead, e.g., something like:

Tr[IdentityMatrix[d] . IdentityMatrix[d]]

although in this case you would need some extra code for simplification (as you can find in my TensorSimplify package). Install the paclet with:

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

Once installed, you can load the package with:

<<TensorSimplify`

Then:

Tr[IdentityMatrix[d] . IdentityMatrix[d]] //TensorSimplify

d

Update

(For the updated question)

Using symbolic tensors, your customAnsatz function can be written:

IXI = TensorProduct[IdentityMatrix[d], IdentityMatrix[d]];

ansatz[s_] := s.s (
    C1 IXI + 
    C2 (TensorTranspose[IXI, {1, 4, 3, 2}] + TensorTranspose[IXI, {1,3,2,4}])
)

Then, your sum can be written:

$Assumptions = (C1|C2) ∈ Complexes && s ∈ Vectors[d];

TensorContract[
    TensorProduct[IXI, ansatz[s]],
    {{1, 5}, {2, 6}, {3, 7}, {4, 8}}
] //TensorSimplify

2 C2 d s.s + C1 d^2 s.s

Carl Woll
  • 130,679
  • 6
  • 243
  • 355
  • Thank you for your answer. I updated the question more specifically to what I am actually needing. Would be wonderful if you could have a second look. – Ezareth Nov 01 '18 at 02:21
  • Thank you for your update. I am reluctant to do it symbolically as many part of the code depend on that sort of computation and are easier to solve with proper vectors. – Ezareth Nov 01 '18 at 09:09