Note: we show the solution for the statement in the AoPS thread, which is f(yf(x))=x2+f(x)f(y−x).
Solution by hyay.
We claim the only solutions are f(x)≡x, f(x)≡−x, f(x)≡x+1 and f(x)≡1−x, which obviously work. We now show they are the only solutions. Let P(x,y) denote the assertion that f(yf(x))=x2+f(x)f(y−x).
P(0,0):f(0)=f(0)2⟹f(0)=0 or f(0)=1.
Case 1: f(0)=0. Then we have
P(x,0):f(x)f(−x)=−x2.
P(1,1):f(f(1))=1.
⟹P(f(1),f(1)):f(f(1))=f(1)2.
⟹f(1)=1 or f(1)=−1.
If f(1)=1, then P(1,0) gives f(−1)=−1, so.
P(1,x+1):f(x+1)=f(x)+1.
P(−1,x):f(−x)=1−f(x+1).
⟹f(x)=−f(−x)⟹P(x,0):f(x)=x or f(x)=−x.
Suppose there exists x=0 such that f(x)=−x, then f(x+1)=−x+1, which is neither x+1 nor −x−1, contradiction. Hence, f(x)=x for all x∈R.
If f(1)=−1, then we can similarly prove f(x)=−x for all x.
Case 2: f(0)=1
P(1,0):f(1)f(−1)=0⟹f(1)=0 or f(−1)=0.
Notice that if f(x) is a solution, then f(−x) is also a solution, so WLOG assume f(1)=0.
Claim 1: f is surjective.
Proof. P(x+1,x):f((x+1)f(x))=x2, so all nonnegative reals are in the range of f.
P(x,f(x)1):0=x2+f(x)f(f(x)1−x) where x,f(x)=0, then there exists t such that f(t)<0.
P(t,x):f(xf(t))=t2+f(t)f(x−t), since f(t)f(x−t) can take any negative value, all negative reals are in the range of f.
Hence, f is surjective.
Suppose u,v∈R so that f(u)=21 and f(v)=−1.
Claim 2: If f(x)=f(y) for some x,y∈R, then x2=y2.
Proof.
P(v,−x):f(−x−v)=v2−f(x).
P(x,−v):f(−vf(x))=x2+f(x)(v2−f(x)).
Comparing P(x,−v) and P(y,−v) gives our desired result.
Claim 3: f(21)=21.
Proof.
P(v,−x):f(−x−v)=v2−f(x).
P(v,2v):f(−2v)=2v2.
P(u,−v):f(−2v)=u2+21(v2−21)=2v2+u2−41⟹u=21 or u=−21.
Assume f(−21)=21. Then,
P(−21,−21):f(−41)=43.
P(21,−21:f(41)=41.
P(−41,1):f(43)=41.
contradicting Claim 2, so f(21)=21.
Now, we have
P(21,21):f(41)=43.
P(21,x):f(21x)=21f(x−21)+41.
P(41,x):f(41x)=41f(x−43)+169.
⟹41f(x−43)+169=f(41x)=21f(21x−21)+41=41f(x−23)+83.
⟹f(x+43)=f(x)−43.
Finally,
P(x,43):f(43f(x))=x2+f(x)f(43−x)=(x2+f(x)f(−x))−43f(x)=1−43f(x).
and since f is surjective, f(x)=1−x for all x∈R. After removing our assumption, we get two solutions, f(x)=x+1 and f(x)=1−x.