Find all functions $f: \mathbb{R} \rightarrow \mathbb{R}$ for which

$$
x f(x + x y) = x f(x) + f\left(x^2\right) f(y)
$$

for all $x, y \in \mathbb{R}$.
Substituting $x=0$ and $y=0$ gives $0=f(0)^{2}$, so $f(0)=0$. Substituting $x=1$ and $y=-1$ gives $f(0)=f(1)+f(1) f(-1)$, so $0=f(1)(1+f(-1))$, hence $f(1)=0$ or $f(-1)=-1$. Substituting $x=-1$ gives

$$
-f(-1-y)=-f(-1)+f(1) f(y) \quad \text { for all } y \in \mathbb{R}
$$

Assume that $f(1)=0$, then it follows that $-f(-1-y)=-f(-1)$ and since $-1-y$ can take all values in $\mathbb{R}$, this means that $f$ is constant. Since $f(0)=0$, it must be that $f(x)=0$ for all $x$. It is clear that this function satisfies the original equation. Thus, we have found the first solution: $f(x)=0$ for all $x \in \mathbb{R}$.
Now assume further that $f(1) \neq 0$, so $f(-1)=-1$. Substituting $y=-1$ into (4), we get $-f(0)=-f(-1)+f(1) f(-1)$, so $0=1-f(1)$, hence $f(1)=1$. Substituting $x=1$ into the original equation gives

$$
f(1+y)=1+f(y) \quad \text { for all } y \in \mathbb{R}
$$

Furthermore, substituting $y=-1$ into the original equation gives $x f(0)=x f(x)-f\left(x^{2}\right)$, so

$$
x f(x)=f\left(x^{2}\right) \quad \text { for all } x \in \mathbb{R}
$$

The original equation can now be written as

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

If $x \neq 0$, we can divide both sides by $x$ and applying (5) gives

$$
f(x+x y)=f(x) f(1+y) \quad \text { for } x \neq 0
$$

Note that this is also true for $x=0$. Now let $z=1+y$. Since this can take all values in $\mathbb{R}$, we get

$$
f(x z)=f(x) f(z) \quad \text { for all } x, z \in \mathbb{R}
$$

Applying this to (6), we find

$$
x f(x)=f\left(x^{2}\right)=f(x) f(x),
$$

so for all $x$ we have $f(x)=0$ or $f(x)=x$. Suppose there is an $x \neq 0$ with $f(x)=0$, then

$$
1=f(1)=f\left(x \cdot \frac{1}{x}\right)=f(x) f\left(\frac{1}{x}\right)=0,
$$

a contradiction. Therefore, for all $x \neq 0$ we have $f(x)=x$. This is also true for $x=0$. Substituting into the original equation shows that this is a solution. The two functions that satisfy are thus $f(x)=0$ for all $x \in \mathbb{R}$ and $f(x)=x$ for all $x \in \mathbb{R}$.