2. [7] Find all functions $f: \mathbb{R} \rightarrow \mathbb{R}$ such that, for all real numbers $x, y$,
$$
(x-y)(f(x)-f(y))=f(x-f(y)) f(f(x)-y) .
$$
Answer: $f(x)=0, f(x)=x$ First, suppose that $f(0) \neq 0$. Then, by letting $x=y=0$, we get that either $f(f(0))$ or $f(-f(0))$ is zero. The former gives a contradiction by plugging in $x=f(0), y=0$ into the original equation. Thus, $f(-f(0))=0$.
Now plugging in $x=0, y=-f(0)$ gives that $f(2 f(0))=f(0)$. Finally, we note that by symmetry of the left hand side of the functional equation, $f(x-f(y)) f(f(x)-y)=f(y-f(x)) f(f(y)-x)$, and letting $y=0$ and $x=2 f(0)$ we get $f(f(0)) f(f(0))=f(-f(0)) f(-f(0))=0$, giving and so $f(f(0)=0$, again a contradiction. Therefore, $f(0)=0$.
Setting $y=0$ yields $x f(x)=f(x) f(f(x))$, so if $f(x) \neq 0$, then $f(f(x))=x$. On the other hand, setting $y=f(x)$ yields $(x-f(x))(f(x)-f(f(x))=f(x-f(f(x))) f(0)$, so in fact $f(f(x))=f(x) \rightarrow f(x)=x$. Thus, for all $x, f(x)=0$ or $f(x)=x$.
Clearly, $f \equiv 0$ satisfies the original equation, so suppose there exists a non-zero $x$ with $f(x)=x$. Then, for all $y \neq x$, if $f(y) \neq 0$, the original equation yields $x(x-y)=x f(x-y)$. Thus, $f(x-y)=x-y$. Similarly, if $f(y)=y$, we find $(x-y)^{2}=f(x-y)^{2}$, so $f(x-y)=x-y$. It follows that $f$ must be the identity, which indeed is a solution to the original equation. The proof is complete.