How find the function $f(f(x)+xy)=f(x)+xf(y),\forall x,y\in R$ Find all function $f:R\to R$ and such
$$f(f(x)+xy)=f(x)+xf(y),\forall x,y\in R$$
Let $x=y=0$,then $$f(f(0))=f(0)$$
 A: Replace $x=0$ in the given identity, we get
$ f(f(0)) = f(0).$
If we let $f(0) = a$, then 
$$f(a) = a\tag{1}.$$
Replace $y=0$ in the given identity, we get
$$f(f(x)) = f(x) + xf(0) = f(x) + ax.\tag{2}$$
Let $x=a$ in (2), we get
$$f(f(a)) = f(a) + a^2.\tag{3}$$
But from (2), $f(f(a)) = f(a) = a$. So (3) becomes
$$a = a + a^2,\text{or } f(0) = 0.$$
Therefore, (2) becomes
$$ f(f(x)) = f(x), \forall x\in \mathbb R.\tag{4}$$
Replace $x$ by $f(x)$ in the given identity, we have
$$f(f(f(x)) + f(x)y) = f(f(x)) + f(x)f(y).$$
Since $f(f(x)) = f(x)$, we have
$$f(f(x) (y+1)) = f(x)(1+f(y)), \forall x,y.\tag{5}$$
Let $y=-1$ in (5), we see that 
$$ 0 = f(0) = f(x)(1+f(-1)), \forall x.$$
Since $f(x)\not\equiv 0$, $f(-1) = -1$. Now replace $x=-1, y=1$ in (5), we get
$$f(-2) = - 1 - f(1), \forall y.\tag{6}$$
We will now show that $f(1)\ne 0$. Indeed, assume that $f(1)=0$, then $f(-2)=-1$. Replace $x=-1, y=-2$ in (5), we get
$$f(f(-1)(1-2)) = f(-1)(1-2).$$
Since $f(-1)=-1$, the above becomes a contradiction $f(1) = 1$.
Thus we showed that $f(1) = b\ne 0$. Replace $1=1$ in the given identity, we have
$$f(b + y) = b + f(y).$$ 
This and (4) implies that
$$f(b+f(y)) = f(f(b+y)) = f(b+y) = b + f(y), \forall y.\tag{7}$$
Moreover, replace $y=b/x$ in the given identity we get
$$f(f(x) + b) = f(x) + xf(\frac{b}{x}),\forall x\ne 0.$$
The above and (7) gives
$$ b + f(x) = f(x) + xf(\frac{b}{x}), \forall x\ne 0,$$
or 
$$ \frac{b}{x} = f(\frac{b}{x}), \forall x\ne 0.$$
Since $b\ne 0$, it follows that $f(x)=x$ for all $x\ne 0.$ Thus $f(x) = x$ for all $x\in \mathbb R$.
A: Let denote that $f^0(x) = x$ and that for positive integer $n$, $f^n(x)=f(f^{n-1}(x))$.
It is easily proven by direct calculation that for every positive integer $n$ and every real $x$, $f^n(x)=f(x)+xf(0)$.
This fact implies that $f(f(x)-x)=f(x)-x +f(x)f(0)-xf(0)$.
But substituting $y = -1$, for every real $x$ provides $f(f(x)-x)=f(x)+xf(-1)$.
Thus we get that  $[1+f(0)+f(-1)]x=f(x)f(0)$ which shows that $f(0)=0$.
Using $f(0)=0$, we can see that for every positive integer $n$ and every real $x$, $f^n(x)=f(x)$.
So $f(f(x)-x)=f(x) - x$. 
Since $f(f(x)-x)=f(x)+xf(-1)$, it leads to $f(-1)=-1$.
Now we have that for every real $x$, $f(f(x)-x)=f(x)- x$, and this implies that $f(f^2(x)-f(x))=f^2(x)-f(x)$ equivalent to $f(x)-x=f(0)=0$.
Therefore $f(x)=x$.
Notice that the case $f(x)=C$ for $C$ a real constant, we get that $C=C+Cx$. Thus $C = 0$ and $f(x)=0$.
A: Partial attempt. Similar to ones above. However, I add some other properties.

We begin noticing that if we take $x = y = 0$ then $f(f(0)) = f(0) = a$. Now, taking $y=0$ and $x = a$, we get
$$
f(f(a)) = f(a) + a^2 \implies a = a + a^2 \implies a = f(0) = 0.
$$
Notice that if $x \neq 0$ we can choose $y$ to make some interesting cancellation. Since
$$
f(x) + xy = x \quad \iff y = \frac{x - f(x)}{x}.
$$
Using this value for $y$, we obtain
$$
x \cdot f\Big(\frac{x - f(x)}{x}\Big) = 0, \quad \forall x \neq 0
$$
and since $x \neq 0$ we have $f\Big(\frac{x - f(x)}{x}\Big)$ is identically zero. Let $Z = f^{-1}(0)$; we know that $Z \ni 0$. For any $x_0 \in Z$, putting $x = x_0$ on the original equation:
$$
f(x_0 y) = x_0 f(y), \quad \forall y \in \mathbb{R}.
$$
Here, we consider some cases of possible $Z$.
If $Z = \{0\}$. Then, we have $1 - \frac{f(x)}{x} = 0$, for every $x \neq 0$ and then we have $f(x) = x$.  
If $|Z| \geq 2$. Then $Z$ has a non-zero element, $x_0$. Taking $y = x/x_0$ gives:
$$
f(x) = x_0 f(x/x_0)
$$
and putting $x = x_0$ we get
$$
0 = f(x_0) = x_0 \cdot f(1),
$$
implying that $f(1) = 0$ and thus $1 \in Z$. Also, $Z$ has some nice algebraic properties:


*

*if $z_1, z_2 \in Z$ are non-zero then $z_1 \cdot z_2 \in Z$; just taking $x_0 = z_1$ and $y = z_2$ above.

*if $z \in Z$ is non-zero, $z^{-1} \in Z$.
If $Z = \{0, 1\}$. We conclude that $f(x) = x$ for $x \neq 1$ and $f(1) = 0$. But this is not possible, since $x = -1$ and $y=-2$ on original equation reaches a contradiction.
If $Z$ has more elements than $0, 1$.
Then, by the algebraic properties $z^n \in Z$ for every integer $n$.

Notice that if $z \in Z$ and $z \neq 0$, then $z \notin \mathrm{Im} f$. Otherwise, taking $x$ with $f(x) = z$ and $y = 0$ would give
$$
0 = f(z) = z 
$$
A: Define $f^1(x)=f(x)$ and for all integer $n \ge 1$, $f^{n+1}(x)=f(f^n(x))$.
At first, we prove some results as following.
Lemma 1. For all integer $n \ge 1$ and $x$ real, $f^n(f(x)+xy)=f(x)+xf^n(y)$.
Proof: 
It is obvious for $n=1$ and $2$. Suppose $f^n(f(x)+xy)=f(x)+xf^n(y)$, we shows the lemma is still true for $n+1$. As $f^{n+1}(f(x)+xy)=f(f(x)+xf^n(y))$, substituting $y = f^n(y)$ gives $f(x)+xf(xf^n(y))$, hence $f^{n+1}(f(x)+xy)=f(x)+xf^{n+1}(y)$.
Lemma 2. There exist real $t$ satisfying $f(t)=0$.
Proof: 
For $x$ nonzero, substitute $y={1-f(x) \over x}$ to get $f(1-{f(x) \over x})=0$. So $t= 1-{f(x) \over x}$.
Lemma 3. For all integer $n \ge 1$ and $x$ real, $f(0)=f(x)+xf^{n}({-f(x) \over x})$.
Proof: 
By using Lemma 1 for $x = 0$, we get $f^{n+1}(0)=f(0)$. For nonzero real $x$ and $y=\frac{-f(x)}{x}$,this gives us $f(0)=f(x)+xf^n({-f(x) \over x})$.
Now we can use these lemmata to show that $f(x)=x$ or $f(x)=0$.
By Lemma 2 and 3, we get $f(0)=f(0)+tf^n(0)$ which is equivalent to $f(0)(1-\frac{f(x)}{x})=0$.
So if $f(0)$ is nonzero then $f(x)=x$.
For $y=0$, Lemma 1 implies that $f^{n+1}(x)=f(x)+xf(0)$ with all integer $n \ge 1$ and real $x$. 
If $f(0)=0$ then for all integer $n \ge 1$ and real $x$, $f^{n+1}(x)=f(x)$. Combining with Lemma 3, it implies that $f(x)+xf(-f(x)/x)=0$. Then $f^2(-1)=f(-1)$.
Taking $y=-1$ then Lemma 1 leads to $f^n(f(x)-x)=f(x)+xf(-1)$. Now for $x=t$, $f^n(-t)=tf(-1)$ hence $f(-t)=tf(-1)$. 
So $f(x)$ is of the form $Cx$ with some constant $C$. As $f^2(x)=f(x)$, we get that $C=0$ or $C=1$ which shows that $f(x)=x$ or $f(x)=0$.
A: This is not complete solution. I don't know how to finish lemma 2. Any idea?
Say $f$ is not identical $0$.
For $y=0$ we get $f(f(x)) = f(x)+xa \;$where $a=f(0)$. Notice that $f(a)=a$ by seting $x=0$, so if we put now $x=a$ we get $a=a+a^2$ so $a=0$, which means $$\boxed{f(f(x)) = f(x)}$$
for all $x$. 

Lemma 1 $f(-1)=-1$ 
Proof: By letting $x=f(t)$ where $t$ is an arbitrary real we have $$f(f(t)+f(t)y) = f(t)+f(t)f(y)$$
Since exists $d$ such that $f(d)\ne 0$ we get by putting $t=d$ and $y=-1$: $$\boxed{f(-1) =-1}$$

Lemma 2  If $f(x)=0$ then $x=0$. 
Proof: Say exists $c\neq 0$ so that $f(c)=0$. Then if $x=c$ we get $$f(yc)=cf(y)$$ so $f({1\over c}) =0$.
Now let $x=c$ and $y=1/c$ then we get $f(1)=0$.

Let now $y= {f(x)\over x}-1$ for $x\neq 0$, then we have $$f\Big({f(x)\over x}-1\Big)=0$$ and since by lemma 2 number $0$ is the only zero we have $f(x)=x$ for all $x$.
