Finding all the surjective functions $ f: \mathbb{R} \to \mathbb{R}$ which satisfy $f(x+f(x)+xy)=2f(x)+xf(y) \ \forall x, y \in \mathbb{R}$ 
Find the function(s) $ f: \mathbb{R} \to \mathbb{R}$ which satisfies these two conditions:

*

*$f(x+f(x)+xy)=2f(x)+xf(y) \ \forall x, y \in \mathbb{R}$

*function $f$ is surjective ($\forall z \in \mathbb R, \ \exists x \in \mathbb R, \ f(x)=z$).


My attempt:
\begin{align}
&\text{let }P(x, y): \ f(x+f(x)+xy)=2f(x)+xf(y) \\
&P(0, y): \ f(f(0))=2f(0). \\
&P(x, 0): \ f(x+f(x))=2f(x)+xf(0). \\
\ \\
&\text{let } f(a)=f(b). \ \\
&P(a, -1): f(f(a))=2f(a)+af(-1). \\
&P(b, -1): f(f(b))=2f(b)+bf(-1). \\
& \Rightarrow a=b \text{ if } f(-1) \neq 0. \\
\ \\
&\text{Edit: }\\
& \text{if } f(-1)=0: \\
&P(x, -1): \ f(f(x))=2f(x). \\
& \text{Since the function } f \text{ is surjective, } f(x)=2x \text{ for } \forall x \in \mathbb{R}. \\
& x=-1; \ f(-1)=-2, \text{ which is contradiction.} \\
\ \\
&\therefore f(a)=f(b) \Rightarrow a=b.
\end{align}
Well, I expect this function to be $f(x)=x. $
Can you show the full process of finding the function(s)?
 A: Posted in AoPS.
\begin{align}
&\text{let } f(t)=0. \\
&P(t, 0): \ f(t+f(t))=2f(t)+tf(0). \\
&\therefore t \cdot f(0)=0. \Rightarrow t = 0 \text{ or } f(0)=0, \text{ which both tells that }f(0)=0. \\
&\therefore f(0)=0. \\
\ \\
&\text{Assume) } \exists c \text{ s.t. } f(c)=0, \ c\neq0. \\
&P(c, -1): 0=cf(-1). \\
&\therefore f(-1)=0 \text{ or } c = 0. \\
\ \\
&\text{if } f(-1)=0: \\
&P(x, -1): \ f(f(x))=2f(x). \\
&\text{let } f(u)=-1. \\
\ \\
&\Rightarrow P(u, -1): f(-1)=-1, \text{ Contradiction.} \\
&\therefore c=0, \text{Contradiction.}
\ \\
&\therefore f(t)=0 \Leftrightarrow t=0. \\
\ \\
&P(x, -1): \ f(f(x))=2f(x)+xf(-1). \\
&x=-1; \ f(f(-1))=f(-1). \Rightarrow \ -1\text{ is a fixed point.} \\
\ \\
&\Rightarrow  f(-1)=f(f(f(-1)))=2f(f(-1))+f(-1)^2 = 2f(-1)+f(-1)^2. \\
\ \\
&\therefore f(-1)=-1 \ (\because f(-1) \neq 0.) \\
\ \\
&\text{Back to }P(x, -1): \ f(f(x))=2f(x)-x. \\
\ \\
&P(-1, 0): f(-2)=-2. \\
\ \\
&P(f(x), -2): 2f(f(x))+f(x)f(-2)=0. \\
\ \\
&\Rightarrow 4f(x)-2x-2f(x)=0. \\
\ \\
&\therefore 2f(x)=2x, f(x)=x, \text{ which is the only solution of the function } f. \\
\end{align}
