RE: Rebuilding polygon from CoefficientList?

*To*: mathgroup at smc.vnet.net*Subject*: [mg20191] RE: [mg20164] Rebuilding polygon from CoefficientList?*From*: "Ersek, Ted R" <ErsekTR at navair.navy.mil>*Date*: Tue, 5 Oct 1999 04:04:21 -0400*Sender*: owner-wri-mathgroup at wolfram.com

Holger Strauss wrote: ------------------------ I have a mixed polynomial poly in several variables vars. cl = CoefficientList[poly, vars] gives a multi-dimensional matrix of coefficients. Can anyone help with an algorithm/expression that re-constructs the original poly given cl and vars? (In practice, I'd like to manipulate the coefficients before reconstructing the polynomial; otherwise this wouldn't make sense). ----------------------------- My solution is given below. It should work quite well. In[1]:= terms[coeff_,expon_List,vars_List]:= coeff*Times@@MapThread[Power,{vars,expon}] CoefficientsToPolynomial[coeffs_,vars_]/; Length[Dimensions[coeffs]]===Length[vars]:= Plus@@Flatten[MapIndexed[terms[#1,#2-1,vars]&,coeffs,{-1}]] In[3]:= cl=CoefficientList[(2+3x-2y+z)^3, {x,y,z}] Out[3]= {{{8, 12, 6, 1}, {-24, -24, -6, 0}, {24, 12, 0, 0}, {-8, 0, 0, 0}}, {{36, 36, 9, 0}, {-72, -36, 0, 0}, {36, 0, 0, 0}, {0, 0, 0, 0}}, {{54, 27, 0, 0}, {-54, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}}, {{27, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}}} In[4]:= poly=CoefficientsToPolynomial[cl,{a,b,c}]; Factor[poly] Out[4]= (2 + 3*a - 2*b + c)^3 You might want to read about CoefficientList, MapIndexed at my web page. The URL is given below. -------------------- Regards, Ted Ersek For Mathematica tips, tricks see http://www.dot.net.au/~elisha/ersek/Tricks.html