Let P(x,y) denote the problem assertion. We claim that a function f:R→R satisfies P(x,y) for all x,y∈R iff f satisfies ∣f(x)∣=∣x∣ for all x∈R and f(x)=x whenever x≥0.
Let us quickly verify all such f work. Since f(x)2=x2 for all x∈R, we have f(x)2+f(y)2=x2+y2≥0. Hence, f(f(x)2+f(y)2)=x2+y2.
It remains to show that these are the only solutions. To begin, let us focus on the behavior of f over R≥0. For any x≥0, we have f(f(x)2+f(0)2)=x, so every x≥0 is the output of f for some input f(x)2+f(0)2≥0. For any r≥0, we may then choose a=f(4r)2+f(0)2 and b=2f(0)2 to verify that f(r)=a2+b2≥0 for all r≥0. It follows that the restriction of f to R≥0 is a surjection to R≥0.
We observe that over the nonnegatives, f in fact bijects to R≥0. Indeed, to show injectivity over the R≥0, we simply note that f(x)=f(y) implies f(2f(x)2)=f(2f(y)2)=2x2=2y2 for any x,y≥0.
Since f(2f(x)2)=2x2, we know 8f(x)4=f(2f(2f(x)2)2)=f(8x4), so f(0),f(21)∈{0,21}. We have f(2f(0)2)=0 and f(2f(21)2)=21, so we also know f(0)=21 iff f(21)=0. It follows that f(41)=f(f(0)2+f(21)2)=41.
Evaluating P(41,x) yields f(161+f(x)2)=161+x2. Nesting this gives 161+(161+f(x)2)2=f(161+f(161+f(x)2)2)=f(161+(161+x2)2). Expanding, we have 25617+81f(x)2+f(x)4=f(25617+81x2+x4). Since 25617<21, pick t∈R satisfying 25617+81t2+t4=21. We obtain f(21)=25617+81f(t)2+f(t)4≥25617, so necessarily f(21)=21 and f(0)=0.
Given f(0)=0, we then have f(f(x)2)=x2 by P(x,0); a second application yields f(x)4=f(f(f(x)2)2)=f(x4). By P(f(x)2,y), we find f(x4+f(y)2)=f(f(f(x)2)2+f(y)2)=f(x4)+y2; writing w=x4, we have f(w+f(y)2)=f(w)+y2 for any w≥0; call this assertion Q(w,y). Recalling that any r≥0 may be written as f(y)2 for some y≥0, we obtain f(w+r)≥f(w) for any w,r≥0, so f is nondecreasing over R≥0.
Notice that f(2f(x)2)=2x2=2f(f(x)2). Letting r=f(x)2, we have f(2r)=2f(r) for any r≥0. Since f(21)=21, it follows that f(2n)=2n for any n∈Z. Applying Q(w,2n), we then find f(w+4n)=f(w)+4n for any n∈Z; since f(0)=0, it follows that that f(4nm)=4nm for any n,m∈Z with m≥0.
We have proven f(x)=x for all x in a dense subset of R≥0, so we are essentially done. Any x≥0 may be approximated by 4nm≤x≤4n(m+1) to arbitrarily high precision by taking n→−∞; since f(4nm)≤f(x)≤f(4n(m+1)), this forces f(x)=x for all x≥0. As for x<0, one simply notes that f(f(x)2)=x2=f(f(−x)2), from which ∣f(x)∣=f(−x)=−x follows from the injectivity of f over R≥0. This concludes the proof.