Solution by megarnie.
The answer is f≡0, f(x)=x, and f(x)=−x, which all work. Let P(x,y) denote the given assertion. Clearly 0 is the only constant solution, so assume f is not constant.
Claim: f is injective.
Proof: Assume f(a)=f(b) for some reals a=b. WLOG a is nonzero. Let r=ab. From P(x,a) compared with P(x,b) we get f(xa)=f(xb). So since ax can take any real, we have f(x)=f(rx) for all reals x. P(x,y) compared with P(rx,y) gives xf(x)=rxf(rx)=rxf(x). Since r=1, we deduce that xf(x)=0 for all x∈R. Thus, f(x)=0 for all x=0.
Now, if we set x and y nonzero in the original equation, the LHS becomes f(0) and the RHS becomes 0, so f(0)=0. Therefore, f≡0, a contradiction because f is nonconstant. □
Claim: f(0)=0.
Proof: P(0,0):f(2f(0)2)=f(0), so injectivity concludes. □
P(−1,1) gives that f(−1)(f(−1)+f(1))=0. Since f is injective, f(−1)=0 cannot hold, so f(−1)+f(1)=0.
P(1,y):f(f(1)2+f(1)f(y))=f(1)+f(y).
P(−1,−y):f(f(−1)2+f(−1)f(−y))=−f(−1)+f(y)=f(1)+f(y).
Combining the two and using the fact that f is injective, we see that
f(1)2+f(1)f(y)=f(−1)2+f(−1)f(−y),
so f(1)f(y)=f(−1)f(−y), which implies f(y)=−f(−y) for each y, so f is odd.
P(x,−x):0=xf(x)+f(−x2)=xf(x)−f(x2), so f(x2)=xf(x).
P(x,0):f(f(x)2)=xf(x). By using injectivity, we get f(x)2=x2.
Now, assume there existed a,b=0 with f(a)=−a and f(b)=b. Note that f(a)=a, f(b)=−b.
P(a,b):f(a2−ab)=a2+f(ab).
P(b,a):f(b2−ab)=f(ab)−b2.
We have two cases, either when f(ab)=ab or when f(ab)=−ab. If f(ab)=ab, then we have f(a2−ab)=a2+ab. So either a2−ab=a2+ab or a2−ab=−(a2+ab), but both cases imply either a=0 or b=0, a contradiction.
If f(ab)=−ab, then f(b2−ab)=−ab−b2. So b2−ab=−ab−b2, or ab−b2=−ab−b2, but both cases again imply ab=0, absurd.
Therefore, we get a contradiction, so f(x)=x for all x or f(x)=−x for all x.