MathGroup Archive 1995

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

Search the Archive

Re: Recombining CoefficientList

  • To: mathgroup at smc.vnet.net
  • Subject: [mg2531] Re: [mg2501] Recombining CoefficientList
  • From: Allan Hayes <hay at haystack.demon.co.uk>
  • Date: Thu, 16 Nov 1995 01:46:38 -0500

sherod at boussinesq.Colorado.EDU (Scott Herod)
in mathgroup at smc.vnet.net
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?

Here is a slight modification of tmj  5.3 p24 (In[] and Out[])

ToPolynomial[cl_, vars_] :=
   Plus@@Flatten[
   	MapIndexed[#1 Times@@(vars^(#2-1))&,cl,{Depth[cl]-1}]
   ]

Example:

poly = a x^3 + b x^4 y + c x y + d y^2 + e

          3              4        2
   e + a x  + c x y + b x  y + d y

cl = CoefficientList[poly, {x,y}]

   {{e, 0, d}, {0, c, 0}, {}, {a, 0, 0}, {0, b, 0}}

ToPolynomial[cl, {x,y}]

          3              4        2
   e + a x  + c x y + b x  y + d y


Allan Hayes
hay at haystack.demon.co.uk



  • Prev by Date: help
  • Next by Date: Re: Re: Imaginary ...
  • Previous by thread: Re: Recombining CoefficientList
  • Next by thread: Re: Re: Recombining CoefficientList