Solution by Anonymous.
The zero function is a solution. Now suppose f is not identically zero, and choose a with f(a)=0. Let P(x,y) denote
f(f(x)2+f(x)f(y))=f(x2)+yf(x).
If f(u)=f(v), then comparing P(a,u) and P(a,v) gives u=v, so f is injective. Also, as y varies in P(a,y), the right side f(a2)+yf(a) takes all real values, so f is surjective.
Since f is surjective, let b be the unique real number such that f(b)=0. From P(b,y),
f(0)=f(b2).
By injectivity, b2=0, so b=0. Hence f(0)=0, and 0 is the unique zero of f.
Now P(x,0) gives
f(f(x)2)=f(x2).
By injectivity, f(x)2=x2, so for every x we have f(x)=x or f(x)=−x.
Let c=f(1), so c=±1. From P(1,y),
f(1+cf(y))=c(1+y).
Taking absolute values using f(t)2=t2, we obtain
∣1+cf(y)∣=∣1+y∣.
Since f(y)=±y, this forces f(y)=cy for every y. Therefore f(x)=x for all x, or f(x)=−x for all x.
Together with the zero function, the full solution set is
f(x)≡0,f(x)=x for all x,f(x)=−x for all x.
All three are checked directly to work.