Solution by AIME4096.
We claim that the complete solution set is f≡0 and f(x)=x∀x∈R, both of which clearly satisfy the equation. We now prove that these are the only solutions. Let P(x,y) denote the assertion f(f(x)2+xf(y))=f(x)2+yf(x) for all x,y∈R.
Lemma 1. We have f(0)=0.
Proof. Assertion P(0,y) gives f(f(0)2)=f(0)2+yf(0) for every y∈R. The left-hand side and the first term on the right-hand side are independent of y, so necessarily f(0)=0. From now on, suppose that f≡0. □
Lemma 2. The function f is bijective.
Proof. Since f≡0, choose a∈R such that f(a)=0. Assertion P(a,y) gives f(f(a)2+af(y))=f(a)2+yf(a). As y ranges over R, the right-hand side ranges over all of R, since f(a)=0. Thus f is surjective. Now suppose for the sake of contradiction that some u,v∈R exist such that u=v and f(u)=f(v). Applying P(a,u) and P(a,v) gives f(f(a)2+af(u))=f(a)2+uf(a) and f(f(a)2+af(v))=f(a)2+vf(a). The left-hand sides are equal because f(u)=f(v), contradiction. Thus f is injective, and hence bijective. □
Lemma 3. We have f(t)=t for every t≥0.
Proof. Assertion P(0,y) gives f(f(x)2)=f(x)2 for every x∈R. Since f is surjective, for every t∈R there exists x∈R such that f(x)=t. Therefore f(t2)=t2 for every t∈R. Every nonnegative real number is a square, so f(t)=t for every t≥0. □
Lemma 4. Every nonzero solution is the identity function.
Proof. Let x∈R. If x=0, then f(x)=0=x by Lemma 1. Now suppose x=0. Since f is injective and f(0)=0, we have f(x)=0. Choose y>0 such that f(x)2+xy≥0. Such a y always exists. For example, if x>0, any y>0 works, while if x<0, it suffices to choose 0<y≤−xf(x)2. By Lemma 3, since y>0, f(y)=y. Therefore P(x,y) gives f(f(x)2+xy)=f(x)2+yf(x). But the argument of f on the left is nonnegative, so Lemma 3 gives f(f(x)2+xy)=f(x)2+xy. Hence f(x)2+xy=f(x)2+yf(x). Thus xy=yf(x). Since y>0, we obtain f(x)=x. Therefore f(x)=x for every x∈R. □
Hence the complete solution set is f≡0 and f(x)=x∀x∈R as desired. ■