MathGroup Archive 1999

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

Search the Archive

Re: Rebuilding polygon from CoefficientList?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg20216] Re: Rebuilding polygon from CoefficientList?
  • From: "Allan Hayes" <hay at haystack.demon.co.uk>
  • Date: Wed, 6 Oct 1999 21:06:33 -0400
  • References: <7t8but$gcv@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Holger Strauss <strauss at ika.ruhr-uni-bochum.de> wrote in message
news:7t8but$gcv at smc.vnet.net...
>
> Hallo,
>
> 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).
> The algorithm must be able to handle any number of vars.
> I've found a solutions for a small and fixed number of vars
> using some ugly nested For loops. However, I suppose
> that there must be a more efficient solution using some cute
> matrix operations.
>
> Many thanks,
> Holger
>
>
> Holger Strauss
> Institute of Communication Acoustics
> Ruhr-University Bochum
>

Holger:

ToPolynomial[cl_, vars_] :=
  Dot @@ Reverse[Append[Flatten[{vars}]^(Range[Dimensions[cl]] - 1), cl]]

Test:

poly =  (3 x -2) (x -y)^2 (1+z)//Expand;
vars = {x,y,z};
cl1= CoefficientList[poly,vars];

ToPolynomial[cl1, vars] // Expand;

% - poly // Expand

0

cl2 = CoefficientList[poly, x];

ToPolynomial[cl2, x] - poly // Expand

0

The part, Flatten[{vars}],  in the code is to deal with when  vars is not a
list.


--
Allan
---------------------
Allan Hayes
Mathematica Training and Consulting
Leicester UK
www.haystack.demon.co.uk
hay at haystack.demon.co.uk
Voice: +44 (0)116 271 4198
Fax: +44 (0)870 164 0565




  • Prev by Date: Inverting a non-square matrix
  • Next by Date: Re: Drawing Rectangular Grid
  • Previous by thread: RE: Rebuilding polygon from CoefficientList?
  • Next by thread: Re: creating input cell with unevaluated expression -- answers