Solution by maromex/jatloe/OronSH.
Let P(x,y) denote the given assertion f(x2+f(x)f(y))=f(x)2+xy.
Claim: f is injective.
Proof: For any real numbers a and b, if f(a)=f(b), then by P(1,a) and P(1,b) we get f(1)2+a=f(1+f(1)f(a))=f(1+f(1)f(b))=f(1)2+b, which means a=b. □
P(0,y) : f(f(0)f(y))=f(0)2 for all real y. As f is injective and f(0)2 is a constant in y, f(0)f(y) must be a constant in y. So either f(y) is constant or f(0)=0. Constant functions f do not work, so f(0)=0.
P(x,0):f(x2)=f(x)2. This means P(1,0):f(1)=f(1)2. We have f(1)=0 because f is injective, so f(1)=1 instead.
P(1,y):f(1+f(y))=1+y.
P(1,1+f(y)):f(1+(1+y))=1+(1+f(y)) which means
f(y+2)=f(y)+2.(⋆)
Plug in y=0 into (⋆) to get f(2)=2.
P(2,y):f(4+2f(y))=4+2y. By (⋆) we can get f(2f(y))=2y.
Claim: f is surjective.
Proof: f(2f(y))=2y takes all real values. □
P(x,y+2):f(x2+f(x)f(y+2))=f(x)2+x(y+2), which by (⋆) is equivalent to f(x2+f(x)f(y)+2f(x))=f(x)2+xy+2x.
P(x,y+2)−P(x,y):f(x2+f(x)f(y)+2f(x))−f(x2+f(x)f(y))=2x.
Note that f(x)=0 for all x=0 because f is injective and f(0)=0. So if x=0, then, because f is surjective, for any real a there exists y such that f(y)=f(x)a−x2 and therefore a=x2+f(x)f(y). We have
f(a+2f(x))−f(a)=2x=f(2f(x))
for any real a and nonzero real x. For any nonzero real b, plug in x=1+f(2b−1) to get 2f(x)=b and
f(a+b)−f(a)=f(b)
for all reals a and nonzero reals b. This is clearly true for b=0 as well, so f is additive. (f(x+y)=f(x)+f(y) for all reals x and y).
Recall P(x,0):f(x2)=f(x)2. This means f(x2)≥0, so f(x)≥0 for all x≥0. So f is bounded on some nontrivial interval and is additive, which means f(x)=cx for some real c. Plugging this into the given equation, we find that only f(x)=x works.