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

 < Previous Comment Help | Reply To Comment | Reply To Topic
 Author Comment/Response yehuda 02/11/13 08:41am I'll repeat writing Sum[ f[a] , {a[[1]],0,n} , {a[[2]],0,n} , .... , {a[[N]],0,n} ] Means 1. you generate a "vector of variables" 2. you define a function f accepting this "vector of variables" as an argument 3. you extract each entry of this "vector of variables" using the index [[1]], [[2]] etc (square brackets for Part[]) 4. You define all the a[[i]] iterators You may avoid ALL of this (besides 2 above) by automation Using Array + Sequence + Evaluate Sum[f[Array[z, 5]], Evaluate[Sequence @@ Array[{z[#], 0, 2} &, 5]]] Replace Array with Table (more typing) Sum[f[Table[z[i], {i, 5}]], Evaluate[Sequence @@ Table[{z[i], 0, 2}, {i, 5}]]] if you want to be more "didactic" vec = Array[z, 5] vecIterators = {#, 0, 3} & /@ vec Sum[f[vec], Evaluate[Sequence @@ vecIterators]] (*All are the same idea, actually *) 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 Help | Reply To Comment | Reply To Topic