Let $\mathbb{R}$ denote the set of real numbers. Determine all functions $f: \mathbb{R} \rightarrow \mathbb{R}$ such that

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

for all real numbers $x, y$.
Williams Kada's solution. First, let's find (1) its linear solutions, i.e., those of the form $f(x)=a x+b$! Substituting into (1) and expanding and rearranging:

$$
a(x+a(x+y)+b)+b+a x y+b=x+a(x+y)+b+y(a x+b)
$$

$$
\left(a^{2}-1\right) x+\left(a^{2}-a-b\right) y+(a b+b)=0
$$

It is reasonable to think that this can only hold for all $x, y$ if all three coefficients in (*) are zero, which is only true if $(a, b)=(1,0)$ or $(-1,2)$, i.e., $f(x)=x$ or $f(x)=2-x$. This reasoning is not part of the solution, but it suggests that these two will be the only solutions to (1). It is clear that the coefficients of (*) are indeed all zero for these, i.e., that $f(x)=x$ and $f(x)=2-x$ are indeed solutions to (1).

Substitute $x=0$ and then $y=1$ into (1), yielding:

$$
\begin{aligned}
f(f(y))+f(0) & =f(y)+y f(0) \\
f(x+f(x+1)) & =x+f(x+1)
\end{aligned}
$$

First, it is easy to find the possible values of $f(0)$: substituting $y=0$ into (2) gives $f(f(0))=0$, and substituting $y=f(0)$ into (2) gives

$$
f(f(f(0)))+f(0)=f(f(0))+f(0)^{2}
$$

i.e., $2 f(0)=f(0)^{2}$, from which $f(0)=2$ or $f(0)=0$.

1. Case: $f(0)=2$, here we expect the solution $f(x)=2-x$.

This case can be handled with a clever observation. Notice that according to (3), $x+f(x+1)$ is a fixed point of $f$ for all $x$. On the other hand, the targeted function $x \mapsto 2-x$ has only 1 as a fixed point. If we could show that in the case $f(0)=2$, $f$ has only 1 as a fixed point, it would follow that $x+f(x+1)$, being a fixed point for all $x$, must be identically 1, i.e., $f(x+1)=1-x$ for all $x$, or $f(t)=2-t$ for any $t$ $(t:=x+1)$.

We will show that in the case $f(0)=2$, $f(a)=a$ implies $a=1$. For this, consider (2) with $y=a$: $f(f(a))+2=f(a)+2 a, a=1$ follows. This proves that in the case $f(0)=2$, $f(x)=2-x$.

2. Case: $f(0)=0$, here we expect the solution $f(x)=x$.

This time we proceed more complicatedly: we notice that if we substitute $-x,-y$ for $x, y$ in (1), $f(x y)$ remains the same, and thus we can write:

$$
\begin{aligned}
& f(x y)=-f(x+f(x+y))+(x+f(x+y))+y f(x) \\
& f(x y)=-f(-x+f(-x-y))+(-x+f(-x-y))-y f(-x)
\end{aligned}
$$

Here, $x+y$ and its negative often cause confusion, it is more convenient to use the notation $y:=k-x$:

$$
\begin{gathered}
-f(x+f(k))+(x+f(k))+(k-x) f(x)= \\
=-f(-x+f(-k))+(-x+f(-k))-(k-x) f(-x)
\end{gathered}
$$

To solve, we first determine some values of $f( \pm k)$, and then compare the resulting equations to express $f(x)$.

We already know that $f(0)=0$, so let's substitute $k=0$ into (4), making it friendlier:

$$
\begin{gathered}
-f(x)+x-x f(x)=-f(-x)-x+x f(-x) \\
2 x=(x+1) f(x)+(x-1) f(-x)
\end{gathered}
$$

If we substitute $x=-1$ into (3), we get $f(-1)=-1$ due to $f(0)=0$, and substituting $x=1$ into (5), we get $2=2 f(1), f(1)=1$. Thus, we can substitute $k=1$ into (4):

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

Here, according to (5), $-(1-x) f(-x)$ can be replaced by $2 x-(x+1) f(x)$, so

$$
\begin{aligned}
-f(x+1)+2(x+1) & =(x-1) f(x)-f(-x-1)+2 x-(x+1) f(x) \\
2+2 f(x) & =f(x+1)-f(-x-1)
\end{aligned}
$$

If we write this for $x-1$ instead of $x$, we get

$$
2+2 f(x-1)=f(x)-f(-x)
$$

Multiplying (6) by $(x-1)$ and adding (5):

$$
\begin{aligned}
2(x-1)+2(x-1) f(x-1)+2 x & =(x-1) f(x)+(x+1) f(x) \\
(x-1) f(x-1)+(2 x-1) & =x f(x)
\end{aligned}
$$

Then, substituting $x=-1$ into (6), we get $f(-2)=-2$, and substituting $x=2$ into (6), we get $f(2)=2$.

To finish, substitute $k=2-\mathrm{t}$ into (4):

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

where $f(x+2)-f(-x-2)=2+2 f(x+1)$ holds by (6), so

$$
2(x+2)+(2-x) \cdot(f(x)+f(-x))=2+2 f(x+1)
$$

Multiplying by $(x+1)$, using (7) gives:

$$
\begin{gathered}
2(x+2)(x+1)-(x-2)(x+1) \cdot(f(x)+f(-x))=2(x+1)+2(x f(x)+2 x+1) \\
2\left(x^{2}+3 x+2\right)-2(x+1)-2(2 x+1)=\left(x^{2}-x-2\right)(f(x)+f(-x))+2 x f(x) \\
2 x^{2}=\left(x^{2}+x-2\right) f(x)+\left(x^{2}-x-2\right) f(-x)
\end{gathered}
$$

Multiplying this by $(x-1)$ and using (5):

$$
\begin{gathered}
2 x^{2}(x-1)=(x-1)\left(x^{2}+x-2\right) f(x)+\left(x^{2}-x-2\right)(2 x-(x+1) f(x)) \\
2 x^{2}(x-1)-2 x\left(x^{2}-x-2\right)=\left[(x-1)\left(x^{2}+x-2\right)-(x+1)\left(x^{2}-x-2\right)\right] f(x) \\
2 x\left(x^{2}-x-\left(x^{2}-x-2\right)\right)= \\
=\left[x \cdot(2 x)-\left(2 x^{2}-4\right)\right] f(x)
\end{gathered}
$$

from which it is clear that $f(x)=x$, for any $x$.

So we have two solutions: $f(x)=x$ and $f(x)=2-x$, and we have already verified these.