Solution by Midmogus.
The unique solution is
f(x)=x.
Let t=f(0). From P(0,y),
f(t2)=t.
Suppose f(r)=t. Comparing P(x,0) and P(x,r) gives
f(rx)=t
for every x. If r=0, then f is constant, impossible. Thus r=0 is the only preimage of t. Since f(t2)=t, we get t2=0, so
f(0)=0.
Now
P(x,0):f(f(x)2)=x2,
so f takes every nonnegative value. To see that it also takes every negative value, fix s<0 and choose x<0 with x2=−s. Since f takes all positive values, choose y with
f(y)=−xf(x)2.
Then f(x)2+xf(y)=0, and P(x,y) gives 0=x2+f(xy), so f(xy)=s. Hence f is surjective.
Using P(1,y) and surjectivity, for every real z we have
f(z)=z+1−f(1)2.
Thus f(z)=z+k for a constant k. Substituting this into the original equation gives
(x+k)2+x(y+k)+k=x2+xy+k,
so k(3x+k)=0 for all x. Hence k=0, and f(x)=x.