How to compare two polynomial and keep one of them

I created a automatisation that assign different values to the coefficient of Poly1 (a,b,c,d,e,f), this can be 0, eliminated some expression and in that moment I need to compare with the other polynomial if this expression can be removed, for example I have this:

Poly1:= a + by + cy^2 + dx + exy + fx^2 y^2


and I want to finish like this:

Poly2:= a + y + x + x^2 y^2


So, if assign d=0, x disappear and I dont want that.

I dont care the final coefficient values, only is important keep the order of structure.

i think to use function Length, like this:

IF[Length[Poly1] === 4, True, False]


Is a good idea, but I dont know what term I am going to get.

Other idea is compare the Poly1 and Poly2.

If[Poly1 === Poly2,True,False]


But I need to eliminate the coefficients of Poly1 only for compare and not using === because Poly1 can have more terms that Poly2, while Poly1 contains the terms of Poly2, Poly1 is okay.

• have a look at CoefficientList – george2079 Nov 19 '15 at 22:52
• Welcome to Mathematica.SE! I suggest the following: 0) Browse the common pitfalls question 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Read the faq! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! – Dr. belisarius Nov 20 '15 at 0:08
• You never voted! What a shame! :) – Dr. belisarius Nov 20 '15 at 0:09

poly1 = a + b y + c y^2 + d x + e x y + f x^2 y^2;