Find all functions $f$ from $\mathbb{R}$ to $\mathbb{R}$ satisfying the following condition:

$$
\forall x, y \in \mathbb{R}, \quad f(x f(x+y))=f(y f(x))+x^{2}
$$
For $x=0$, the equation in the statement gives us:

$$
\forall y \in \mathbb{R}, \quad f(0)=f(y f(0))
$$

Suppose, for the sake of contradiction, that $f(0) \neq 0$ and set $y=\frac{x}{f(0)}$ in the above equation. We obtain that $f$ is constant, which is clearly in contradiction with the equation in the statement. Thus, $f(0)=0$.

For $y=0$, the equation in the statement gives us:

$$
\forall x \in \mathbb{R}, \quad f(x f(x))=x^{2}
$$

For $y=-x$, the equation in the statement gives us:

$$
\forall x \in \mathbb{R}, \quad f(-x f(x))=-x^{2}
$$

Combining these two equations, we obtain that $f$ is surjective.

Moreover, if $\alpha$ is a preimage of 0, substituting $x=\alpha$ into the equation $f(x f(x))=x^{2}$ ensures that $0=\alpha^{2}$ and thus $\alpha=0$. The only preimage of 0 is therefore 0.

Let $x$ and $y$ be two real numbers such that $f(x)=f(y)=: c$. We have already handled the case where $c=0$, so we will assume $c \neq 0$. Using the original equation for $x=0$ and then for $y=y-x$, we obtain:

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

Thus, $f((y-x) c)=0$, which implies $(y-x) c=0$, and hence (since $c \neq 0$) $x=y$. Therefore, $f$ is injective. $f$ is thus bijective.

Moreover, the equations $f(x f(x))=x^{2}$ and $f(-x f(x))=-x^{2}$ ensure that:

$$
\forall x \in \mathbb{R}, f^{-1}(x)= \begin{cases}\sqrt{x} f(\sqrt{x}) & \text { if } \quad x \geq 0 \\ -\sqrt{-x} f(\sqrt{-x}) & \text { if } \quad x \leq 0\end{cases}
$$

In particular, $f^{-1}$ is odd, and thus $f$ is also odd.

Using the original equation multiple times, we then obtain:

$$
\begin{aligned}
\forall x, y \in \mathbb{R}, f(y f(x)) & =-x^{2}+f(x f(x+y))=-x^{2}-\left(f((x+y) f(x+y-x))-(x+y)^{2}\right) \\
& =2 x y+f((x+y) f(-y))+(-y)^{2}=2 x y+f(-y f(-y+x+y)) \\
& =2 x y-f(y f(x)) .
\end{aligned}
$$

Thus, we know that, for any $x$ and $y$, $f(y f(x))=x y$. By symmetry, we immediately deduce that $f(x f(y))=x y$. We then obtain that $f(y f(x))=f(x f(y))$, which, by injectivity, can be rewritten as $y f(x)=x f(y)$. Assuming $x$ and $y$ are non-zero, we deduce that $\frac{f(x)}{x}=\frac{f(y)}{y}$. We immediately deduce that this quantity is constant on $\mathbb{R}^{*}$, and thus that $f$ is linear on $\mathbb{R}^{*}$ and then, since $f(0)=0$, that $f$ is linear on $\mathbb{R}$.

After verification, we find that the two only solutions to this functional equation are $\pm$ Id.