Student Support Forum: 'problem with "apply"' topicStudent Support Forum > General > "problem with "apply""

 < Previous Comment | Next Comment > Help | Reply To Comment | Reply To Topic
 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: ,

 Subject (listing for 'problem with "apply"') Author Date Posted problem with "apply" Brian 02/08/13 00:11am Re: problem with yehuda 02/09/13 10:27am Re: Re: problem with Brian 02/09/13 5:13pm Re: problem with yehuda 02/11/13 08:41am
 < Previous Comment | Next Comment > Help | Reply To Comment | Reply To Topic