# Sum of kronecker delta

What else is needed to make Mathematica to simplify the following expression to $z[j]$?

Code:

Assuming[
{n \[Element] Integers, p \[Element] Integers,
i \[Element] Integers, j \[Element] Integers,
r \[Element] Integers, s \[Element] Integers,
n >= 1, p >= 1,
i >= 1, i <= n,
j >= 1, j <= p,
r >= 1, r <= p,
s >= 1, s <= n,
},
FullSimplify[\!$$\*UnderoverscriptBox[\(\[Sum]$$, $$r = 1$$, $$p$$]$$z[r]*\( \*UnderoverscriptBox[\(\[Sum]$$, $$s = 1$$, $$n$$]\*
TemplateBox[{RowBox[{"i", ",", "s"}]},
"KroneckerDeltaSeq"] \*
TemplateBox[{RowBox[{"j", ",", "r"}]},
"KroneckerDeltaSeq"]\)\)\)]
]

• 1) Use KroneckerDelta instead of "KroneckerDeltaSeq" (no idea what's that supposed to mean); 2) what is it that you really want to achieve? As shown, you're multiplying a sum of zs by a sum of $\delta$s - why should it even be equal to z[j]? – corey979 Jan 20 '18 at 8:46
• @corey979 1) "KroneckerDeltaSeq" is produced by copy and paste, replacing it with "KroneckerDelta" doesn't make a difference. 2) I want to simplify the expression to it's simplest form, which IS $z[j]$: The first delta in the second sum is not zero only when $s=i$, thus the second sum resolves to $\delta _{j,r}$, so the second sum is one only when $s=i, r=j$, which makes the entire expression $z[j]$ – Incömplete Jan 20 '18 at 9:03
• @corey979 oh, I think you misunderstood the expression, it's $\Sigma (z \Sigma \_)$, not $(\Sigma z)(\Sigma \_)$ – Incömplete Jan 20 '18 at 9:08
• So you want FullSimplify[ Sum[z[r]* Sum[KroneckerDelta[i, s]*KroneckerDelta[j, r], {s, 1, n}], {r, 1, p}]]. – corey979 Jan 20 '18 at 9:29
• Yes, but just using the above equation (FullSimplify...) wouldn't yield the desired result. – Incömplete Jan 20 '18 at 12:27

Try this:

    FullSimplify[
Sum[z[r]*Sum[
KroneckerDelta[i, s] KroneckerDelta[j, r], {s, 1, n}], {r, 1,
p}], {{i, j, n, p, s, r} \[Element] Integers, n >= 1, p >= 1,
i >= 1, j >= 1, r >= 1, i <= n, j <= p, s <= n, r <= p}]


yielding the following:

Have fun!

• The code in the question also produces this output, the problem is, it is not the simplest form. – Incömplete Jan 20 '18 at 14:30
• Here's an observation: DiscreteDelta[j - r] // PiecewiseExpand gives the bracketed expression in the answer above. Is there an inverse to PiecewiseExpand? – bill s Jan 20 '18 at 15:09