How to solve the functional equation $ f(xf(y)+y^2)-f(xy)=f(2x+y^2)-2$? I am trying to solve the functional equation given by
$$\forall x, y \in \mathbb{R}:\;\;\; f(xf(y)+y^2)-f(xy)=f(2x+y^2)-2.$$
I have already tried using the classical ways (symmetry, injection, surjection... etc.), but without finding a complete answer.
Are there some ideas?
 A: The only solutions are the constant function $f(x)=2$ and the function $f(x)=x+2$.
Plugging $x=y=0$ we find $f(0)=2$.
If $f(y)=2$ for some nonzero $y$ then we obtain $f(xy)=2$ for any $x$. This means that $f(x)=2$ for all $x$. The constant function $f(x)=2$ works.
From now on assume that $f(y)\neq 2$ for $y\neq 0$. If $y$ is such that $f(y)\neq y$ then we can plug in $x=\frac{y^2}{y-f(y)}$. We obtain $0=f(\frac{2y^2}{y-f(y)}+y^2)-2$ from which it follows that $\frac{2y^2}{y-f(y)}+y^2=0$. From this we obtain $f(y)=y+2$.
We prove now that $f(y)\neq y$ for any $y$. Define the function $g(t)=f(t)-t$. Note that $g(t)\in\{0,2\}$ for all $t$. Rewriting the equation in terms of $g$ we obtain $g(xf(y)+y^2)+xg(y)-g(xy)=g(2x+y^2)+2x-2$. Suppose that $f(y)=y$ for some $y$ and plug in $x=\pi$. We obtain $g(\pi f(y)+y^2)-g(\pi y)=g(2\pi+y^2)+2\pi$. This is a contradiction as the lefthandside is an integer and the righthandside is irrational. Therefore $f(y)\neq y$ for all $y$. This forces $f(y)=y+2$ for all $y$. The function $f(x)=x+2$ clearly works.
