Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2005
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2005

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Interaction of Sum/Plus and KroneckerDelta

  • To: mathgroup at smc.vnet.net
  • Subject: [mg55244] Re: [mg55178] Interaction of Sum/Plus and KroneckerDelta
  • From: Andrzej Kozlowski <akoz at mimuw.edu.pl>
  • Date: Thu, 17 Mar 2005 03:30:15 -0500 (EST)
  • References: <200503161035.FAA23756@smc.vnet.net> <a7454fce3ae1c6ad98c491a9b18cb3ab@mimuw.edu.pl>
  • Sender: owner-wri-mathgroup at wolfram.com

On 16 Mar 2005, at 19:11, Andrzej Kozlowski wrote:

> On 16 Mar 2005, at 11:35, Ofek Shilon wrote:
>
>> I'm fighting Mathematica 5.1.0 to perform a (seemingly) elementary
>> simplification, and Mathematica - so far - wins, so i thought i'd
>> consult some veterans.
>> Here's a simplified example of the problem.
>>
>> type:
>> Sum[KroneckerDelta[i, j], {i, 1, 5}]
>>
>> and you get:
>> KroneckerDelta[1, j] + KroneckerDelta[2, j] +
>>   KroneckerDelta[3, j] + KroneckerDelta[4, j] + KroneckerDelta[5, j]
>>
>> which i want to simplify to 1.  The direct approach:
>> Simplify[%, Assumptions -> {j âË?Ë? Integers, 0 < j < 3}]
>>
>> still gives:
>> KroneckerDelta[1, j] + KroneckerDelta[2, j]
>>
>> Can Mathematica somehow automatically transform this to 1?
>> modification of the original sum are welcome too, of course.
>>
>>   thanks for any ideas,
>>
>>     Ofek Shilon
>>
>>
>>
>
> I think the closest you can get to the answer you want is by using 
> Matheamtica 5.1's new function  Piecewise. You have to define your own 
> KroneckerDelta:
>
> KD[i_, j_] := Piecewise[{{1, i == j}}]
>
> and then use Simplify:
>
> In[2]:=
> Simplify[KD[1, j] + KD[2, j] +
>    KD[3, j] + KD[4, j] + KD[5, j]]
>
> Out[2]=
> Piecewise[{{1, j == 1 ||
>      j == 2 || j == 3 ||
>      j == 4 || j == 5}}]
>
>
> Unfortunately the answer is a Piecewise object rather than one and 
> including assumption sin Simplify such as 1<=j<=5 does not help.
>
>
> Andrzej Kozlowski
> Chiba, Japan
> http://www.akikoz.net/andrzej/index.html
> http://www.mimuw.edu.pl/~akoz/
>
Actually, I was not quite correct.

Let again

KD[i_, j_] := Piecewise[{{1, i == j}}]

This does not work as one might have hoped:


Simplify[KD[1, j] + KD[2, j] + KD[3, j] + KD[4, j] +
    KD[5, j], j â?? Integers && 1 <= j <= 5]


Piecewise[{{1, j == 1 || j == 2 || j == 3 || j == 4 ||
      j == 5}}]

but this:


Simplify[KD[1, j] + KD[2, j] + KD[3, j] + KD[4, j] +
    KD[5, j], Or @@ Thread[j == Range[5]]]

1

does and to me seems the best solution to your problem.

Andrzej Kozlowski


  • Prev by Date: How can I compute the Fourier transform of a unit disk and a unit ball analytically by using Mathematica?
  • Next by Date: Re: Re: Do loops in Mathematica
  • Previous by thread: Re: Interaction of Sum/Plus and KroneckerDelta
  • Next by thread: Re: Interaction of Sum/Plus and KroneckerDelta