Message Boards Message Boards

1
|
8007 Views
|
8 Replies
|
3 Total Likes
View groups...
Share
Share this post:

Simplify sums with Kronecker deltas?

Posted 5 years ago

Hi, I am defining a sum using the following code:

mySum = Sum[a[i] b[i], {i, 1, n}]

Then I do:

myValue = D[mySum, a[k]]

Which naturally gives: $\sum _{i=1}^n b(i) \delta _{i,k}$. Since no assumptions are made, Mathematica can do nothing more to simplify the expression. But then I do:

Simplify[myValue, k >= 1 && k <= n]

Which mathematically is $b(k)$ under the assumptions that $k\geq 1$ and $k\leq n$. But the simplification is not made. Is there a natural way in which Mathematica can deal with such simplifications?

I am trying the trial version of Mathematica, and I have to decide whether to buy it or not. I did not have to much time to try everything, but I did my best. I also looked on the web, and there does not seem to be a natural solution there. I would like Mathematica to do the simplification automatically given the right assumptions.

Thank you!

8 Replies

Hi Jose, thank you for your reply,

I am not sure if I understand everything completely, but it seems to me dangerous that the $\text{simplifyDelta}$ function outputs $m(k,l)$. The reason for this is that $m(k,l)$ could theoretically be non-zero while the values of $k$ and $l$, for example, be greater than $n$ (the upper bound on the sums ( $\sum _{i=1}^n \sum _{j=1}^n m(i,j) \delta _{i,k} \delta _{j,l}$)). In that case, no simplifications should be made because there is not enough information given to the function. ( $\sum _{i=1}^n \sum _{j=1}^n m(i,j) \delta _{i,k} \delta _{j,l} = 0$ if $k>n$ or $l>n$). But I am sure there is a way to construct a nice Mathematica function to deal with this. I will explore the package you suggested me : )

Hi Guillaume,

Indeed, those Kronecker deltas should be absorbed if there is enough information to make sure that the indices are in the proper ranges to guarantee coincidences. We are working on this problem, but it will take a bit more time to be in the system.

In the meantime, there are some tricks that you can use in simple cases. For example let us build the simplifyDelta function:

restrictedSum[e_, {{a_, ___}}, a_] := e;
restrictedSum[e_, {l___, {a_, ___}, r___}, a_] := Sum[e, l, r];

simplifyDelta[expr_] := expr //. {
    HoldPattern[Sum[e_ KroneckerDelta[a_, b_], inds__]] :> restrictedSum[ReplaceAll[e, a -> b], {inds}, a] /; ! FreeQ[e, a],
    HoldPattern[Sum[e_ KroneckerDelta[a_, b_], inds__]] :> restrictedSum[ReplaceAll[e, b -> a], {inds}, b] /; ! FreeQ[e, b]
    };

Now take for example a case with two sums:

mySum = Sum[a[i] m[i, j] b[j], {i, 1, n}, {j, 1, n}]

and take a second derivative, so we get two deltas:

In[]:= D[mySum, a[k], b[l]]
Out[]= Sum[KroneckerDelta[i, k] KroneckerDelta[j, l] m[i, j], {i, 1, n}, {j, 1, n}]

In[]:= % // simplifyDelta
Out[]= m[k, l]

Of course, you need to avoid repetition of symbols (both in indices and in names of indexed objects). The eventual algorithm in WL will handle all these things automatically.

Let me finally point out that there are several powerful Wolfram Language packages to handle indexed objects, and probably one of them can help you already. See for example xAct (www.xact.es).

Is this solved now? I have a similar problem where if I define

W = Sum[u[c[x, t + a, a], l[x, t + a, a]], {x, 1, N}]
dWdc = FullSimplify[D[W, c[y, a + t, a]], N >= y && y >= 1 && y \[Element] Integers ]

I still get Delta[x,y] in the output. What am I doing wrong?

POSTED BY: Henrik Schachner

It seems the Kronecker delta accepts non-integer values, so I also tried to specify that $k$ had to be an integer, but it does not work either:

mySum = Sum[a[i] b[i], {i, n0, n1}]
myValue = D[mySum, a[k]]
myValue /. {n0 -> 1, n1 -> n}
Simplify[myValue /. {n0 -> 1, n1 -> n}, 
 k >= 1 && k <= n && Element[k, Integers]]

outputs $\sum _{i=1}^n b(i) \delta _{i,k}$

I am sorry, the code you gave works, I think I had variables already defined somewhere. But it does not seem like it could solve my problem if I only want to sum over a finite range.

Hi Henrik, thank you for your reply,

I won't necessarily always want to sum over all of the integers. I tried the code you suggested and the only result I get is: $\sum _{i=-\infty }^{\infty } b(i) \delta _{i,k}$. I also added the following line of code:

TeXForm[Simplify[myValue /. {n0 -> -Infinity, n1 -> Infinity}]]

And I still don't get the simplification, that is $\sum _{i=-\infty }^{\infty } b(i) \delta _{i,k}$. It would be helpful if Mathematica were able to do simple simplifications like this. The actual simplification I wanted to make was not this one, but it partly illustrates the point.

I cannot say, why your code is not giving the obvious simplification. One workaround could be to define the summation limits "on demand":

mySum = Sum[a[i] b[i], {i, n0, n1}]
myValue = D[mySum, a[k]]
myValue /. {n0 -> -Infinity, n1 -> Infinity}
POSTED BY: Henrik Schachner
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract