Solution by jasperE3.
Let P(x,y) be the assertion f(xf(x)+xf(y))=x2+f(x)f(y).
P(0,x)⇒f(0)=f(0)f(x).
If f(0)=0 then f(x)=1 for all x, which, upon checking, is not a solution. Contradiction, so we have to have f(0)=0.
P(x,0)⇒f(xf(x))=x2⇒[0,∞)⊆f(R).
From this we also get (x=1) that f(f(1))=1 and so (x=f(1)) f(1)2=1.
Similarly, f(−f(−1))=1 and so f(−1)2=1.
Case 1: f(1)=1
P(1,x)⇒f(1+f(x))=1+f(x), so f(x)=x for all x≥1 since f(x)+1 takes any value ≥1.
If f(−1)=−1:
P(−1,x)⇒f(1−f(x))=1−f(x), so f(x)=x for all x≤1 since −f(x)+1 takes any value ≤1.
Combining these two statements, f(x)=x.
It remains to consider the subcase f(−1)=1.
Let x>0 and take some large y>max{1,x1−f(x)}, we have f(xf(x)+xf(y))=f(xf(x)+xy)=xf(x)+xy and so:
P(x,y)⇒xf(x)+xy=x2+yf(x).
Varying y, we see that f(x)=x for all x>0.
P(−1,x)⇒f(−1−f(x))=1+f(x), so f(x)=−x for all x≤−1 since −f(x)−1 takes any value ≤−1.
Let x<0 and take some small y<min{−1,x1+f(x)}, we have f(xf(x)+xf(y))=f(xf(x)−xy)=−xf(x)+xy and so:
P(x,y)⇒−xf(x)+xy=x2−yf(x).
Varying y, we see that f(x)=−x for all x<0.
Combining our two conclusions here with f(0)=0, we have f(x)=∣x∣ which is indeed a solution.
Case 2: f(1)=−1
P(1,x)⇒f(−1+f(x))=1−f(x), so f(x)=−x for all x≥−1 since f(x)−1 takes all values ≥−1.
In particular, f(−1)=1 so:
P(−1,x)⇒f(−1−f(x))=1+f(x), so f(x)=−x for all x≤−1 since −f(x)−1 takes all values ≤−1.
Therefore f(x)=−x for all x which is indeed a solution.