This won't really fit in a comment, but I wanted to briefly expand on Patrick Stevens
' and Bob Hanlon
's answers. If they would like to incorporate this answer into theirs, I will delete this answer.
In order to generalize the clever observation that
{1, var1, …, var1^n}.CoefficientList[poly, {var1, var2}].{1, var2, …, var2^m}
is the polynomial in question when there are two variables, there is a variant in which Dot
works to reconstruct the polynomial in an arbitrary number of variables.
By way of example, take
poly = x + y^2 + z^3;
vars = {x, y, z};
cl = CoefficientList[poly, vars];
degrees = Exponent[poly, vars];
We can reconstruct the polynomial from the CoefficientList
cl
and the list of polynomial degrees degrees
with
Dot[cl, Sequence @@ Reverse @ MapThread[PowerRange[1, #1^#2, #1] &, {vars, powers}]]
To pick this apart, note that
Reverse @ MapThread[PowerRange[1, #1^#2, #1] &, {vars, powers}]
merely automates creating the lists of monomials:
(* {{1, z, z^2, z^3}, {1, y, y^2}, {1, x}} *)
We have to reverse the list because the ordering of the tensors in Dot
matters. Then, Dot
does the rest.
1
,x
,x^2
,...,x^5
and each column corresponds to1
,y
,y^2
; and the entries corresponds to their products. $\endgroup$CoefficientList
under "Properties & Relations." $\endgroup$