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?
 A: 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).$$
A: You can consider the polynomial in the ring $\mathbb{Q}(y)[x]$.
The criterion that a polynomial $g(x)\in F[x]$, $F$ a field, is divisible by $(x-a)^2$ is that $g(a)=g'(a)=0$.
In your case $F=\mathbb{Q}(y)$ (the field of fractions of $\mathbb{Q}[y]$), $a=-y$ and the derivative is the partial derivative with respect to $x$, of course.
So, if $f(x,y)\in\mathbb{Z}[x,y]$ satisfies $f(x,-x)=0$ and $f_1(x,-x)=0$, where $f_1$ denotes the partial derivative with respect to the first variable $x$, then there exists $g\in\mathbb{Q}(y)[x]$ such that
$$
f(x,y)=(x+y)^2g(x,y)
$$
However, $g(x,y)$ must be a polynomial in $\mathbb{Z}[x,y]$, because we can do long division with respect to $x$, as $(x+y)^2$ is monic as a polynomial in $x$, and long division will never exit from $\mathbb{Z}[x,y]$.
The converse is also clear: if $f(x,y)=(x+y)^2g(x,y)$, with $g(x,y)\in\mathbb{Z}[x,y]$, then $f(x,-x)=0$ and
$$
f_1(x,y)=2(x+y)g(x,y)+(x+y)^2g_1(x,y)
$$
so also $f_1(x,-x)=0$.
A: $(x+y)^2$ is a factor of $f(x,y)$ iff both $f(x,-x)=0$ and $f'(x,-x)=0$, 
