summation involving Kronecker Deltas

I see that:

Sum[u[q] u[k] v[k1] v[k + k1 + q] KroneckerDelta[k1 - q], {k1, -\[Infinity], \[Infinity]}]

produces the correct result: u[k] u[q] v[q] v[k + 2 q]

However:

Sum[u[q] u[k] v[k1] v[k + k1 + q] KroneckerDelta[k - q], {k1, -\[Infinity], \[Infinity]}]

does not give

Sum[u[q] u[q] v[k1] v[k1+2*q], {k1, -\[Infinity], \[Infinity]}]

as I would like to. Can this be done?

Also, a similar thing occurs in multiple summations involving KroneckerDelta or DiscreteDelta, e.g:

Sum[u[q] u[k] v[k1] v[k + k1 + q] KroneckerDelta[k1 - q],
{q, -\[Infinity], \[Infinity]}, {k,-\[Infinity], \[Infinity]}, {k1, -\[Infinity], \[Infinity]}]

doesn't give as output:

Sum[u[q] *u[k]*v[q]*v[k + 2*q] KroneckerDelta[k1 - q],
{q,-\[Infinity], \[Infinity]}, {k,-\[Infinity],\[Infinity]}]

Any suggestions?

• The output of the second example is correct, because MMA can not know if q==k or q !=k. However the problem is here: if one sums over k1 and k, the output is not evaluated. Dec 17, 2020 at 20:42
• How can MMA not know that q=k in the second example since KroneckerDelta[k - q] is included?
– geom
Dec 17, 2020 at 21:17
• Your are summing over k1 not k. If k != q the sum is zero. Dec 17, 2020 at 21:24
• true, so how can I make it understand that I want q==k and not q!=k ?
– geom
Dec 17, 2020 at 22:09
• Simple, use k everywhere instead of q. (or the other way round) Dec 18, 2020 at 8:27