MathGroup Archive 1995

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Recombining CoefficientList

  • To: mathgroup at smc.vnet.net
  • Subject: [mg2504] Re: Recombining CoefficientList
  • From: mtrott (Michael Trott)
  • Date: Wed, 15 Nov 1995 01:59:45 -0500
  • Organization: Wolfram Research, Inc.

In article <489hte$gm7 at ralph.vnet.net> sherod at boussinesq.Colorado.EDU  
(Scott Herod) writes:
> CoefficientList[poly, {x1,x2,...,xn}] returns an array of coefficients
> of the various powers of the xi in poly.  Has someone got a code segment
> to recreate poly from the list of xi and the output?

FromCoefficientListToPolynom[coeffList_List, varList_List] :=
Plus @@ Flatten[MapIndexed[(#1 Inner[Power, varList,
                 #2 - 1, Times])&, coeffList, {Length[varList]}]]


example:


In[6]:=  CoefficientList[(x^3 + 7x - y)^3, {x, y, z}]

Out[6]= {{{}, {}, {}, {-1}}, {{}, {}, {21}, {}}, {{}, {-147}, {}, {}}, 
 
>    {{343}, {}, {3}, {}}, {{}, {-42}, {}, {}}, {{147}, {}, {}, {}}, 
 
>    {{}, {-3}, {}, {}}, {{21}, {}, {}, {}}, {}, {{1}, {}, {}, {}}}

In[7]:= FromCoefficientListToPolynom[%, {x, y, z}]

             3        5       7    9        2         4        6
Out[7]= 343 x  + 147 x  + 21 x  + x  - 147 x  y - 42 x  y - 3 x  y + 
 
           2      3  2    3
>    21 x y  + 3 x  y  - y

In[8]:= Factor[%]

                3     3
Out[8]= (7 x + x  - y)


--
Michael Trott
Wolfram Research, Inc.


  • Prev by Date: Bug in CoefficientList?
  • Next by Date: Re: Writing big files with Mathematica
  • Previous by thread: Recombining CoefficientList
  • Next by thread: Re: Recombining CoefficientList