I have tried to have mathematica replace the kronecker delta in the summation, but I have not obtained result, the index remain the same.

First i define the derivative the z-function in function of index.

         z /: D[z[i_, j_], z[m_, n_], NonConstants -> {z}] := KroneckerDelta[i, m]*KroneckerDelta[j, n];    
         zz /: D[zz[i_, j_], zz[m_, n_], NonConstants -> {zz}] := KroneckerDelta[i, m]*KroneckerDelta[j, n] ;  

For example if take

            A=Sum[z[m, n]*zz[m, n], m, n], m, n];

And then take the derivative with repect to z, I obtain

           D[A,z[1,1],NonConstants -> {z}]= Sum[KroneckerDelta[1, m] KroneckerDelta[1, n] zz[m, n],m,n]

How can I make mathematica evaluate the kronecker delta and eliminate sumations?.

Thank you very much

  • 1
    $\begingroup$ Your second code block has a misplaced right bracket (or a missing left bracket), and it's not obvious exactly how to fix it. $\endgroup$ Commented Aug 31, 2017 at 19:51

1 Answer 1


Straight from the Mathematica documentation for KroneckerDelta, we have

Use in sums to pick out elements:

Sum[KroneckerDelta[a, 3] f[a], {a, Infinity}]
(* f[3] *)

So when we issue the command

Sum[KroneckerDelta[1, m] KroneckerDelta[1, n] zz[m, n], {m, Infinity}, {n, Infinity}]

Mathematica returns z[1,1], which I suspect is what you want. Unfortunately, since your code for A is currently broken, I can't address how to modify that definition so that this happens.

  • $\begingroup$ thanks very much, your response was very helpful $\endgroup$
    – Arturo_222
    Commented Sep 1, 2017 at 0:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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