McLaughlin, James on Sat, 04 Jun 2011 21:03:01 +0200 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
RE: Multiple Summation Question |
Thanks!! I was doubtful whether that was possible, but your neat program did what I wanted ( except f(i,J)=1+prod(j=1,i,J[j])+2^(i*J[i]-(i-1)*J[i-1]) not ^ f(i,J)=1+prod(j=1,i,J[i])+2^(i*J[i]-(i-1)*J[i-1]) ^ ). Now that you have explained the method, I will be able to adapt for what I really want to do. Thanks again, Jimmy Mc Laughlin ________________________________________ From: Bill Allombert [Bill.Allombert@math.u-bordeaux1.fr] Sent: Saturday, June 04, 2011 5:51 AM To: pari-users@list.cr.yp.to Subject: Re: Multiple Summation Question On Sat, Jun 04, 2011 at 03:09:39AM +0000, McLaughlin, James wrote: > >Well, you can start by defining a function f that takes i, [j_1,...,j_k] and the other parameters ^^^^^^^^^^^^^ > >and returns f_i (j_1,j_2, ..., j_i, other parameters). > > >At this point you should be able to finish with forvec. > > Displaying my ignorance again, but I don't see how to define such a function f in k variables j_1,j_2, ..., j_k when k is a parameter that changes. You missed the brackets above: the idea was to pass the variables as a single vector > Just to keep it simple, set j_0=0, and > F(k)= > Sum_{j_1=1}^1 Sum_{j_2=1}^2 ... Sum_{j_k=1}^k > Product_{i=1}^k f_i (j_1,j_2, ..., j_i) > where > f_i (j_1,j_2, ..., j_i) = 1+ j_1*j_2*...*j_i + 2^(i*j_i - (i-1)*j_{i-1}). > > I can write a program to evaluate this kind of expression for any particular k, but I still can't really see how to do it for every k. Define f as follow: f(i,J)=1+prod(j=1,i,J[i])+2^(i*J[i]-(i-1)*J[i-1]) F(k)=my(s=0);forvec(J=vector(k,i,[1,i]),s+=prod(i=1,k,f(i,J)));s (you will have to fix f for i=1) Cheers, Bill.