Re: Rebuilding polygon from CoefficientList?
- To: mathgroup at smc.vnet.net
- Subject: [mg20193] Re: [mg20164] Rebuilding polygon from CoefficientList?
- From: BobHanlon at aol.com
- Date: Tue, 5 Oct 1999 04:04:23 -0400
- Sender: owner-wri-mathgroup at wolfram.com
Holger,
reconstructPolynomial[coefMatrix_List, vars_List] :=
Module[{maxPwrs = Dimensions[coefMatrix] - 1, factors, k},
factors =
Table[#[[1]]^k, {k, 0, #[[2]]}] & /@ Transpose[{vars, maxPwrs}];
Flatten[coefMatrix].Flatten[Outer[Times, Apply[Sequence, factors]]]];
poly = a*x^3*y + b*x^2*y^2*z + c*x*y^3*z^2 + d*z^2 + e*t*x*y*z;
var = {x, y, z};
coef = CoefficientList[poly, var];
reconstructPolynomial[coef, var] == poly
True
var = {t, x, y, z};
coef = CoefficientList[poly, var];
reconstructPolynomial[coef, var] == poly
True
Bob Hanlon
In a message dated 10/4/1999 3:10:53 AM, strauss at ika.ruhr-uni-bochum.de
writes:
>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.
>