Solution by jasperE3.
f(f(x)2+f(y)2)=f(x)2+f(y)2.
Let ∅=S⊆R with the closure property that if a,b∈S then a2+b2∈S. Then define:
f(x)={xg(x)if x∈S2+S2if x∈/S2+S2
where S2+S2={a2+b2∣a,b∈S} and g:R∖(S2+S2)→S is any function.
For this choice of f, f(x)∈S for all x∈R so f(x)2+f(y)2∈S2+S2 for all x,y∈R, and therefore f indeed satisfies f(f(x)2+f(y)2)=f(x)2+f(y)2.
To see that all such functions are of this form, take S=f(R).