Re: Time-consuming series coefficients

*To*: mathgroup at smc.vnet.net*Subject*: [mg40262] Re: [mg40230] Time-consuming series coefficients*From*: Daniel Lichtblau <danl at wolfram.com>*Date*: Fri, 28 Mar 2003 04:31:49 -0500 (EST)*References*: <200303271149.GAA22054@smc.vnet.net>*Sender*: owner-wri-mathgroup at wolfram.com

marchibald wrote: > > Hi, > > I have the following function from which I would like to extract the > coefficient of z^{50}, and then expand the result as a series in u: > > f[z_,u_] := Product[1 + u (Exp(zpq^{i - 1}) - 1), {i,50}] > > where p=q=1/2. > > The product from i=1 to 10 can be done in a reasonable amount of time, but > anything larger takes far too long. > > Does anyone have an idea of how to expand f[z,u] as a series quickly, or even > to extract the coefficient of z^{50} some other way? > > Thanks, > > M. Archibald > University of the Witwatersrand One method would be to expand "by hand" subject to a rule that powers of z higher than 50 get discarded. We employ a few other tactics along the way to reduce the computation time. p = q = 1/2; You did not use Mathematica syntax so I assume the function below is what you had in mind. f[z_,u_] := Product[1 + u*(Exp[z*p*q^(i-1)] - 1), {i,50}] We make a list of the factors, and take a power series of each. ll = Apply[List,f[z,u]]; ll2 = Series[ll,{z,0,50}]; Now we remove the denominator from each series, and convert each to a polynomial. We also record the product of the denominators. denoms = Map[LCM[Apply[Sequence,Denominator[#[[3]]]]]&, ll2]; ll3 = ll2 * denoms; ll4 = Normal[ll3]; denom = Apply[Times,denoms]; We set up a rule that forces powers of z larger than 50 to disappear. z^m_ /; m>50 ^= 0; We are now prepared to expand the product of these polynomials. In[10]:= Timing[poly = Fold[Expand[#1*#2]&, 1, ll4];] Out[10]= {433. Second, Null} The desired coefficient is simply coeff = Last[CoefficientList[poly,z]] / denom It is a polynomial in u of degree 50. There may be faster ways to do all this but the approach above seems reasonable given the size of numbers that appear in the polynomials. Daniel Lichtblau Wolfram Research

**References**:**Time-consuming series coefficients***From:*"marchibald" <marchibald@maths.wits.ac.za>