Is there a command equivalent to that of Coefficient to get the terms of a polynomial which are a power of the variables?
For example:
func[(x^3 + x)^2]
{x^2, x^4, x^6}
Thank you in advance
The function MonomialList
extracts the monomials, including the overall factor. You can remove the overall factor using FactorTermsList
. So, a function to do what you want could be:
Last @* FactorTermsList /@ MonomialList[(x^3+x)^2, x, "NegativeLexicographic"]
{x^2, x^4, x^6}
where I used the non-default order "NegativeLexicographic" to obtain the ordering requested.
CoefficientList[ ]
? $\endgroup$func[expr_, x_Symbol] := Cases[Expand[expr], Power[x, _], Infinity] // Union
$\endgroup$