We claim the only solutions are f(x)≡x and f(x)≡−x, which obviously work. We now show they are the only solutions. Let P(x,y) denote the assertion that f(f(x2)+xf(y))=x2+f(x)f(y).
First, P(0,y) yields f(f(0))=f(0)f(y) for all y∈R. Since f cannot be constant, this tells us that f(0)=0. Next, P(x,0) yields f(f(x))=x for all x≥0. Replacing y with f(y) yields that for any x∈R and y≥0,
f(f(x2)+xy)=x2+f(x)y.
For any x=0 and for any y large enough (we need y≥max{0,−x−1}), we have
In particular, for any x>0, there exists a real number Mx such that f(y+1)−f(y)=f(x)/x for any y≥Mx. Thus we get f(x)/x=f(1) via f(x)/x=f(y+1)−f(y)=f(1) for some y≥max{Mx,M1}. Similarly, for any x<0, there exists a real number Mx such that f(y+1)−f(y)=f(x)/x for any y≤Mx. Thus we get f(x)/x=−f(−1) via f(x)/x=f(y+1)−f(y)=−f(−1) for some y≤min{Mx,M1}. In summary, there exist real numbers c1 and c2 such that f(x)=c1x for all x>0 and f(x)=c2x for all x<0.
If c1>0, then f(f(x))=x for all x>0 yields c1=1. Then P(−1,1) yields c2=−f(−1)=1, and so f(x)=x for all x∈R. If c1<0, then f(f(x))=x for all x>0 yields c1c2=1. But then P(1,1) yields c12=1, so c1=c2=−1 and thus f(x)=−x for all x∈R.