<s>[INST] How to identify that a polynomial has factor $(x+y)^2$ About integer polynomial $f(x,y)$, conclusions such as "If $f(x,x)=0$, then $y-x$ is a factor" "If $f(x,wx)=0$, then $x^2+xy+y^2$" is a factor" are easy.
But what about $(x-y)^2$? How to verify, or identify that $f(x,y)$ has a factor $(x+y)^2$? Does differentiation work?
 [/INST] Let $t:=x+y$.
Then we must have
$$P(x,t-x)=t^2Q(x,t-x).$$
E.g.
$$P(x,y)=x^3+x^2-xy^2+2xy-y^3+y^2+yx^2\to P(x,t-x)=2xt^2-t^3+t^2.$$

You can simply check that the polynomial has a double root at $t=0$,
$$\left.P(x,t-x)\right|_{t=0}=P(x,-x)=0,$$
$$\left.\frac{\partial P}{\partial y}(x,t-x)\right|_{t=0}=\frac{\partial P}{\partial y}(x,-x)=0.$$
Indeed
$$x^3+x^2-x(-x)^2+2x(-x)-(-x)^3+(-x)^2+(-x)x^2=0$$
and
$$x^2-2x(-x)+2x-3(-x)^2+2(-x)=0.$$

Another option is to divide by $(x+y)^2=x^2+2xy+y^2$:
$$x^3+x^2-xy^2+2xy-y^3+y^2+yx^2\\
=x(x^2+2xy+y^2)-x^2y+x^2+2xy-y^3+y^2\\
=(x-y)(x^2+2xy+y^2)+x^2+2xy+y^2\\
=(x-y+1)(x^2+2xy+y^2).$$
</s>