| Author |
Comment/Response |
yehuda
|
02/09/13 10:27am
some comments
The behavior you observe is just the order of evaluation so you need to prevent the evaluation of Product until you apply Sum.
You should do it using Hold surrounding Product and then Release surrounding the whole expression
In addition, the is no need to define z={z1,z2} and then work with indices Look at the combined solution below.
In addition, I wonder why you have to mess with that, since you can write it directly, or use Sequence (read the documentation, it is higher level of Mathematica coding)
Using Hold + Release
_______________________
Release[Apply[
Sum, {Hold[Product][If[m > 0, Subscript[z, i], 1], {i, 1, 2}], {m,
0, 1}}]]
_____________________________________
Using dummy name + ReplaceAll
you can also do it replacing Product with some other dummy name and then replace it . Basically it is the same idea of order of evaluation implemented differently
_______________________________________
Apply[Sum, {ff[If[m > 0, Subscript[z, i], 1], {i, 1, 2}], {m, 0,
1}}] /. ff -> Product
HTH
yehuda
URL: , |
|