Solution by iamthehazard.
The answer is f(x)=x only, which clearly works. Let P(x,y) denote the assertion.
If f(t)=0, compare P(0,t) and P(t,t) to get t2=2t2, hence t=0. Then from P(0,0), we get that f(f(0)2)=0, hence f(0)2=0 and f(0)=0.
Now suppose that f(a)=f(b) but a=b. Compare P(0,a) with P(0,b) to get that a2=b2, hence b=−a. Then compare P(a,1) with P(−a,1) to get f(−af(a)+f(1)2)=f(af(a)+f(1))2. Since a,f(a)=0, we can’t have −af(a)+f(1)2=af(a)+f(1)2, but since f(1)2=0, we can’t have −af(a)+f(1)2=−(af(a)+f(1)2) either. Therefore f is injective.
Comparing P(x,0) and P(0,x) therefore gives us xf(x)=f(x)2. If x=0, then f(x)=0 and we have f(x)=x. We already know that f(0)=0, so combining these yields f(x)=x as the only solution.