
A2. Find all functions $f: \mathbb{R} \rightarrow \mathbb{R}$ such that:

$$
f(x y)=y f(x)+x+f(f(y)-f(x))
$$

for all $x, y \in \mathbb{R}$.


Solution. Firstly, considering $(x, y)=(1,1)$ we get $f(0)=-1$.

Then, setting $y=1$, we see that $-x=f(f(1)-f(x))$, so $f$ must be surjective.

Now let $(x, y)=(a, 0)$ and $(0, a)$ to get

$$
-1=a+f(-1-f(a)) \quad \text { and } \quad-1=-a+f(f(a)+1)
$$

Since $f$ is surjective, for any real $z$ we may write $z=f(a)+1$ and then adding these two results gives $f(z)+f(-z)=-2$.

Letting $(x, y)=(a, 1)$ and $(1, a)$ we get

$$
-a=f(f(1)-f(a)) \quad \text { and } \quad f(a)=a f(1)+1+f(f(a)-f(1))
$$

Adding these, and using the previous result with $z=f(a)-f(1)$ gives

$$
f(a)=a f(1)+a-1
$$

So $f(x)=k x-1$ for all $x$, for some fixed $k$. Substituting back into the original equation we see that 1 and -1 are the only possibilities for $k$ and that both of these values do give a function that works.
