0
$\begingroup$

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.

$\endgroup$
  • $\begingroup$ have a look at CoefficientList $\endgroup$ – george2079 Nov 19 '15 at 22:52
  • $\begingroup$ 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! $\endgroup$ – Dr. belisarius Nov 20 '15 at 0:08
  • $\begingroup$ You never voted! What a shame! :) $\endgroup$ – Dr. belisarius Nov 20 '15 at 0:09
2
$\begingroup$
poly1 = a + b y + c y^2 + d x + e x y + f x^2 y^2;
poly2 = a + y + x + x^2 y^2;
c[p_] := CoefficientList[p, {x, y}]
And @@ Flatten@MapThread[Equal, {c@poly1, c@poly2}, 2]

(* b == 1 && c == 0 && d == 1 && e == 0 && f == 1 *)
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.