I have a long polynomial such as
a x^2+ bx^2y+cx^2y^2 +d x^3y^4+e x^4y^3+f y^2+g xy^2
Consider an example problem as follows: I want to output the monomials (along with their coefficients) which have y^2 in them and then write down a polynomial using them. In other words, if y^2 is not contained in the monomial, I want to set its coefficient to 0 and write down the resulting polynomial. For example, the above polynomial will lead to the following
0 x^2+ 0 x^2y+cx^2y^2 +0 x^3y^4+ 0 x^4y^3+f y^2+g xy^2 = cx^2y^2+fy^2+gxy^2
Can MonomialList extract the monomials with a certain structure like the above example?
b * x^2y
, notbx^2y
which equals(bx)^2y
sincebx
is treated as a single variable. $\endgroup$y^2 Coefficient[expr, y^2]
? $\endgroup$