Solution by jasperE3.
The solutions are
f(x)=0,f(x)=x,f(x)=21.
First,
P(0,0):f(0)=2f(0)2,
so f(0)∈{0,21}.
Suppose f(0)=0. Then
f(x2)=f(x)2.(1)
If f(a)=f(b)=0, comparing P(a,y) and P(b,y) gives that f has period a2−b2. If this period were nonzero, (1) would imply f(t)≥0 for all t, while
P(x,−f(x)x2)
would give a negative value whenever f(x)=0, a contradiction. Hence a2=b2. Thus
f(a)=f(b)=0⟹a=±b.(2)
If f(1)=1, then P(1,y) gives f(y+1)=f(y)+1. Comparing P(x,y+1) and P(x,y) gives
f(t+f(x))=f(t)+f(x)
for every t whenever f(x)=0. In particular, f(f(x))=f(x) for such x, so (2) gives f(x)=±x. The negative option is impossible, because if f(k)=−k with k=0, then P(k,k) gives 0=2k2. A nonzero root is also impossible: if f(k)=0 with k=0, then comparing P(x,k) and P(x,0) for x with f(x)=0 forces k=−2 from x=1, contradicting f(4)=4. Therefore f(x)=x.
If f(1)=0, then P(x,1) and (2) imply f(x)∈{0,−2x2} for every x. If f(k)=0, then P(k,k) gives a positive value 8k4, impossible for a function whose values are only 0 and nonpositive numbers. Hence f≡0.
Now suppose f(0)=21. From P(1,0), f(1)∈{0,21}. If f(1)=0, then
P(0,2):f(2)=−21,P(0,4):f(4)=−23,
but P(2,0) gives f(4)=0, a contradiction. Thus f(1)=21.
Then P(1,y) and P(0,y) give
f(1+2y)=41+21f(y)=f(2y),
so f is periodic with period 1. Also
P(x,0):f(x2)=f(x)2+21f(x)≥−161.
By periodicity, f is bounded below by −161 on all of R. If f(x)≥an for all x, then P(0,2x) gives
f(x)=41+21f(2x)≥41+21an.
Starting with a1=−1/16 and iterating, an→1/2, so f(x)≥1/2 for all x.
Finally,
P(x,−f(x)x2)
is valid because f(x)>0, and gives
21=f(x)2+f(x)f(−f(x)x2)≥41+41.
Equality forces f(x)=1/2 for every x. All three listed functions work.