• To: mathgroup at smc.vnet.net
• From: "Jose Luis Gomez" <jose.luis.gomez at itesm.mx>
• Date: Wed, 28 May 2008 04:43:50 -0400 (EDT)
• References: <g15qqi\$pf2\$1@smc.vnet.net> <200805261024.GAA15181@smc.vnet.net>

```Thank you Daniel (and also the other Daniel) for your answers.

Here I just report another case where Sum does not behave the way I want
(which of course it does Not mean it is a Bug, it just means it does not
behave the way I expected)

Consider these calculations:

Clear[j];
Sum[j^2, {j, 1, 10}]

Mathematica gave the answer I was expecting: 385

Now if j has a value:

j = 7;
Sum[j^2, {j, 1, 10}]

Again Mathematica gave the answer I was expecting: 385,
It means the global j and the dummy index j are actually different
That is o.k., that is exactly what I was expecting

It also works in this case:

j = 7;
Sum[j^2, {j, 1, n}]

Again Mathematica gave the answer I was expecting (n*(1 + n)*(1 + 2*n))/6,
It means the global j and the dummy index j are actually different
That is o.k., that is what I was expecting

Next one also works the way I want:

Clear[f,j];
Sum[f[j], {j, 1, n}]

One more time Mathematica gave the answer I was expecting,
It answered Sum[f[j],{j,1,n}] (same expression unevaluated) in the nice
StandardForm,
so that I can manipulate this symbolic expression later.

HOWEVER in the following calculation

Clear[f];
j = 7;
Sum[f[j], {j, 1, n}]

That is NOT what I was expecting
I was expecting that Mathematica will return the Sum unevaluated, Sum[f[j],
{j, 1, n}],
and also with j unevaluated, so that the global j and the dummy index j
remain different.
But that is not what Mathematica 6.0 did in my Windows computer.

This last example, I think, is not consistent with the previous examples,
because the global j and the local j get effectively mixed.
I know it can be done, that the local j never gets mixed with the global j,
even if the sums returns unevaluated,
and that is the behavior I was expecting, because is consistent
with the previous examples and because that is, I think,
the most logical choice.

Thank you, I just wanted to report this unexpected (at least by me)
behavior.

Jose
Mexico

-----Mensaje original-----
De: dh [mailto:dh at metrohm.ch]
Enviado el: Lunes, 26 de Mayo de 2008 05:24 a.m.
Para: mathgroup at smc.vnet.net
different

Ho Jose,

in general an expression sum1 sum2 means the summands of sum1 are sum2.

This is in line with conventions from Mathematica (that is in a double

sum, the first index sums last). Therefore, both expressions are identical.

As there is no description what Equal really does we have to guess. If

we look at the FullForm of your expression, we see that they differ,

only the printed Form is the same. Well, I would gues that Equal

compares the FullForm.

To obtain "True" from Equal we have therefore to ensure that both sides

of the equation have the asme form. E.g.:

t1=Sum[f[j,k],{j,ja,jb},{k,ka,kb}]

t2=Sum[Sum[f[j,k],{k,ka,kb}],{j,ja,jb}]

t1==t2/.{HoldPattern[Sum[v1_,v2_,v3_]]:>Sum[Sum[v1,v3],v2]}

hope this helps, Daniel

Jose Luis Gomez wrote:

> (* Dear group

>

>

>

> In Mathematica 6.0 it is possible to generate Sums with the same

> StandardForm but different InputForm

>

>

>

> In other words, they look exactly the same for the final user, but they
are

> considered different by Mathematica

>

>

>

>

> (PLEASE NOTICE THAT HERE INDEX j GOES FIRST)

>

> *)

>

>

>

> Clear[f,j,k,ja,jb,ka,kb];

>

>

>

> Sum[f[j,k],{j,ja,jb},{k,ka,kb}]

>

>

>

> (* You obtain the sum in "sigma notation" (StandardForm).

>

> Next evaluate the following

>

> (PLEASE NOTICE THAT HERE INDEX k GOES FIRST)

>

>  *)

>

>

>

> Sum[  Sum[f[j,k],{k,ka,kb}],  {j,ja,jb}]

>

>

>

> (*As you can see, both expressions display exactly the same, they look the

> same in StandardForm,

>

>  However they are considered different by Mathematica.

>

> To see this, evaluate:

>

> *)

>

>

>

> Sum[f[j,k],{j,ja,jb},{k,ka,kb}] == Sum[  Sum[f[j,k],{k,ka,kb}],
{j,ja,jb}]

>

>

>

> (* I was expecting to obtain True, as both Sums look exactly the same in
the

> Mathematica notebook.

>

> However Mathematica does Not answer True or False, it just returns

> unevaluated,

>

>

>

> So I have the following questions for those who would like to help me:

>

> FIRST: Am I right? Both expressions are the same? Or is there a situation

> where these two expressions, which look almost identical in StandardFrom,

> are actually different?

>

> SECOND: I have try FullSimplify, Reduce and Refine, trying to obtain True,

> but it does Not work. Is there any command or simplification to make

> Mathematica answer True, maybe under certain assumptions?

>

> THIRD: Could this behavior be considered a bug?

>

> I am using Mathematica 6.0

>

> Thank you for your time and help

>

>

>

> Jose

>

> Mexico

>

> *)

>

>

>

--

Daniel Huber

Metrohm Ltd.

Oberdorfstr. 68

CH-9100 Herisau

Tel. +41 71 353 8585, Fax +41 71 353 8907

E-Mail:<mailto:dh at metrohm.com>

Internet:<http://www.metrohm.com>

```

• Prev by Date: Re: No Show
• Next by Date: RE: Re: Re: No Show