4. determine all functions $f: \mathbb{R} \rightarrow \mathbb{R}$ so that for all $x, y \in \mathbb{R}$ holds

$$
f(x f(x)+f(y))=y+f(x)^{2}
$$

## Solution
Set $x=0$, then follows

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

in particular $f$ is surjective. Choose $a \in \mathbb{R}$ with $f(a)=0$ and set $x=a$ :

$$
f(f(y))=y
$$

A comparison with (1) also shows $f(0)=0$. Inserting $y=0$ now gives

$$
f(x f(x))=f(x)^{2}
$$

Substitute $x=f(z)$ in (3), then follows with (2)

$$
f(z f(z))=z^{2}
$$

Finally, from (3) and (4) we obtain $f(x)^{2}=x^{2}$, i.e. $f(x)= \pm x$ for all $x \in \mathbb{R}$. Assume there are two real numbers $x, y \neq 0$ with $f(x)=x$ and $f(y)=-y$. Substituting into the original equation yields

$$
\pm\left(x^{2}-y\right)=f(x f(x)+f(y))=y+f(x)^{2}=y+x^{2}
$$

If the plus sign applies, then $y=0$ follows, in contradiction to the assumption, if the minus sign applies, then $x=0$ follows, which must also not be the case. Therefore, only the functions $f(x)=x$ and $f(x)=-x$ can be solutions. By substituting, you can easily confirm that both fulfill the functional equation.