Solution by gurt yoll, with the aid of ChatGPT.
The solutions are
f(x)=λx(λ∈R),f(x)=1−x,
and
f(x)={1,0,x=0,x=0..
Let
P(x,y):f(x2+yf(x))=f(x)(x+f(y)).
Putting x=y=0 gives f(0)∈{0,1}.
First suppose f(0)=0. Then
P(x,0):f(x2)=xf(x),
so f is odd. If f≡0, we are done. Otherwise choose values with nonzero image. Comparing P(x,y) and P(−x,y) gives, whenever f(x)=0,
f(x2+t)+f(x2−t)=2f(x2).
Using oddness, this becomes the translation identity
f(t+2x2)=f(t)+2xf(x).(1)
If f(t+h)=f(t)+k for all t, then comparing P(u,y+h) and P(u,y) for any u with f(u)=0 yields
f(t+hf(u))=f(t)+kf(u).(2)
Also, from P(x,−x2/f(x)),
f(f(x)x2)=x(f(x)=0).(3)
Take a,b with f(a),f(b)=0. Since f(b2)=bf(b)=0, equation (3), applied at b2, gives a u with f(u)=b2. Applying (2) to the translation (1) coming from a gives
f(t+2a2b2)=f(t)+2af(a)b2.
Interchanging a and b gives
af(a)b2=bf(b)a2,
so f(a)/a=f(b)/b. Hence f(x)=λx whenever f(x)=0.
There is no nonzero root: if f(y)=0 with y=0, choose x with f(x)=0. Then P(x,y) gives
f(x2+yf(x))=xf(x)=f(x2)=0.
Both arguments have nonzero image, so using f(z)=λz on the nonzero-image set forces y=0, a contradiction. Thus in this case f(x)=λx for all x.
Now suppose f(0)=1. From P(x,0),
f(x2)=(x+1)f(x).
Thus f(1)=0, and comparing x with −x gives
(1+x)f(x)=(1−x)f(−x).(4)
Let x∈/{−1,0,1} and f(x)=0, and set q=(1−x)/(1+x). Comparing P(x,y) with P(−x,qy) gives
f(qy)=qf(y)+1−q.(5)
Putting y=1 yields f(q)=1−q. Since the map x↦(1−x)/(1+x) is an involution, applying the same argument at q gives f(x)=1−x at every nonexceptional point with nonzero image.
If no such point exists, then f vanishes outside {−1,0,1}, with f(0)=1 and f(1)=0. Let c=f(−1). From P(−1,y),
f(1+yc)=c(−1+f(y)).
If c=0, choose y so that both y and 1+yc avoid {−1,0,1}; then the left side is 0 and the right side is −c, impossible. Hence c=0, giving the exceptional solution.
Finally, if a nonexceptional x with f(x)=0 exists, equation (5) produces infinitely many nonexceptional u with f(u)=1−u. For arbitrary y, choose such a u with u=−f(y) and
z=u2+y(1−u)∈/{−1,0,1}.
Then P(u,y) gives
f(z)=(1−u)(u+f(y))=0.
So f(z)=1−z, and therefore
1−u2−y(1−u)=(1−u)(u+f(y)).
Since u=1, this gives f(y)=1−y. The listed functions are all directly checked.