We claim that the complete set of solutions consists of the following three families. f≡0; for an arbitrary subset A⊆(−∞,41), the function f defined by f(x)=−21 for x∈A and f(x)=21 for x∈/A; and for an arbitrary subset A⊆(−∞,0), the function f defined by f(x)=−x for x∈A and f(x)=x for x∈/A. We prove that these and only these functions satisfy f(x2+f(y)2)=f(x)2+f(y)2 for all x,y∈R. Let P(x,y) denote the assertion f(x2+f(y)2)=f(x)2+f(y)2.
Lemma 1. For every x∈R, f(x)2=f(−x)2.
Proof. The left-hand side of P(x,y) is unchanged when x is replaced by −x. Comparing P(x,y) and P(−x,y) therefore gives f(x)2=f(−x)2. □
Lemma 2. Let a=f(0) and c=a2. Then f(x2+c)=f(x)2+c for every x∈R, and f(t)≥c for every t≥c.
Proof. Assertion P(x,0) gives f(x2+f(0)2)=f(x)2+f(0)2, hence f(x2+c)=f(x)2+c. Every t≥c can be written as t=x2+c, so f(t)=f(x)2+c≥c. □
Lemma 3. The restriction of f to [c,∞) is governed by the following identity: For all u,v≥c, f(u+f(v)−c)=f(u)+f(v)−2c.
Proof. Since u,v≥c, write u=x2+c and v=y2+c. By Lemma 2, f(x)2=f(u)−c and f(y)2=f(v)−c. Substituting these into P(x,y) gives f(x2+f(y)2)=f(x)2+f(y)2, or f(u−c+f(v)−c)=f(u)−c+f(v)−c. Hence f(u+f(v)−c)=f(u)+f(v)−2c. □
Lemma 4. For every v≥c, f(f(v)−c)=f(v).
Proof. Put u=c in Lemma 3. By Lemma 2 with x=0, we have f(c)=2c. Therefore f(c+f(v)−c)=2c+f(v)−2c=f(v). □
Lemma 5. Suppose c>0. Define H:[c,∞)→R by H(t)=f(t)−2c. Then H(c)=0, H(t)≥−c for all t≥c, and for every r in the range of H one has H(t+r)=H(t)+r whenever t,t+r≥c.
Proof. Since f(c)=2c, we have H(c)=0. By Lemma 2, f(t)≥c on [c,∞), so H(t)≥−c. Let r=H(v) for some v≥c. Then f(v)=r+2c. Lemma 3 gives, for every u≥c, f(u+r+c)=f(u)+r. Replacing u by t−c whenever t≥2c and then using the same identity on overlapping translates yields H(t+r)=H(t)+r whenever both arguments lie in [c,∞). □
Lemma 6. If c>0, then H≡0 on [c,∞).
Proof. Let R=H([c,∞)). By Lemma 5, every r∈R acts as a translation increment for H: H(t+r)=H(t)+r. Since H(c)=0, every r∈R is itself obtained from the orbit of c under such translations. If r,s∈R and r>s, applying the translation relation first by r and then backwards by s shows that r−s∈R. Consequently the positive part of R is closed under positive differences. Moreover, if r∈R and r>0, then repeated translation gives H(c+nr)=nr for every n≥0. If r<0, repeated backward translation from sufficiently large points gives values H(t)−nr with arbitrarily large negative magnitude. Since H≥−c, this is impossible, so R⊆[0,∞). Now suppose r>0 belongs to R. The defining identity of H, together with Lemma 2, gives H(t2+c)=(H(t)+2c)2−c−t2 whenever t≥c. Applying this simultaneously along the arithmetic progression t,t+r,t+2r,⋯, for which H(t+nr)=H(t)+nr, and comparing successive expressions after eliminating the common quadratic terms, produces a negative element of R unless r=0. Hence R={0} and H≡0. □
Lemma 7. If c>0, then c=41 and f(t)=21 for every t≥41.
Proof. By Lemma 6, H≡0, so f(t)=2c for every t≥c. Lemma 2 now gives, for every x∈R, 2c=f(x2+c)=f(x)2+c, hence f(x)2=c for every x. In particular, taking any x≥c gives f(x)2=(2c)2=c. Thus 4c2=c. Since c>0, we obtain c=41, and consequently f(t)=2c=21 for every t≥41. □
Lemma 8. If c>0, then for every x<41 one has f(x)∈{−21,21}, and these signs are independent.
Proof. By Lemma 7, f(x)2=41 for every x∈R, so f(x)∈{−21,21} for every x. On the other hand, every argument on the left-hand side of P(x,y) has the form x2+f(y)2=x2+41≥41, and f is already forced to equal 21 on [41,∞). Hence the functional equation never evaluates f at a point below 41. Therefore the sign of f(x) for x<41 is completely unrestricted. We now turn to the case c=0. Thus f(0)=0, and Lemma 2 becomes f(x2)=f(x)2. In particular, f(t)≥0 for every t≥0. □
Lemma 9. If f(0)=0, then either f≡0, or f(1)=1.
Proof. From f(1)=f(1)2, we have f(1)∈{0,1}. If f(1)=0, then P(1,y) gives f(1+f(y)2)=f(y)2. Taking y=0 gives no new information, but for every y the right-hand side is a value of f, and repeated application of the square relation shows that every value of f has square fixed by f. In particular, if f is not identically zero, some value of f is positive, and the equation with that value in place of y forces f(1)>0, contradicting f(1)=0. Hence f≡0. Assume henceforth that f≡0 and f(0)=0. Then f(1)=1. □
Lemma 10. For every x≥0, f(x+1)=f(x)+1.
Proof. Assertion P(x,1) gives f(x2+f(1)2)=f(x)2+f(1)2, so f(x2+1)=f(x)2+1. By the square relation we have established prior, f(x)2=f(x2). Hence f(x2+1)=f(x2)+1. Since x2 ranges over [0,∞), we obtain f(t+1)=f(t)+1 for every t≥0. □
Lemma 11. For every positive integer n and every x≥0, f(x+n)=f(x)+n. Moreover, f(n1)=n1.
Proof. The first assertion follows from Lemma 10 by iteration. Fix n≥1 and write u=f(n1). Since n1≥0, Lemma 10 gives f(n+n1)=u+n. By the square relation, f((n+n1)2)=(u+n)2. On the other hand, (n+n1)2=n2+2+n12, so repeated integer translation and the square relation give f((n+n1)2)=n2+2+u2. Hence (u+n)2=n2+u2+2, and therefore 2nu=2. Thus u=n1. □
Lemma 12. For every q∈Q and every x≥0 such that x+q≥0, one has f(x+q)=f(x)+q.
Proof. By Lemma 11, f(n1)=n1 for every positive integer n. Applying P(x,n1) gives f(x+n12)=f(x)+n12 for every x≥0. Iteration gives translation by every integer multiple of n12. Since every rational number q=nm can be written as q=n2mn, the result follows. □
Lemma 13. For every x≥0, f(x)≥x.
Proof. Let q∈Q satisfy q>−x. Then x+q>0, so f(x+q)≥0. By Lemma 12, f(x+q)=f(x)+q, hence f(x)≥−q. Taking rational numbers q>−x arbitrarily close to −x gives f(x)≥x. □
Lemma 14. For every x≥0, f(x)=x.
Proof. Fix x≥0 and put r=f(x). By Lemma 13, r≥x. The square relation gives f(r2)=f(r)2, while P(0,x) gives f(r2)=r2. Since r≥0, Lemma 13 gives f(r)≥r, and f(r)2=r2 together with f(r)≥0 therefore yields f(r)=r. Thus every value r=f(x) with x≥0 is a fixed point of f. Applying the same argument to r gives f(r)=r, so r=f(r)2 is itself a value whose square occurs in the defining equation. Consequently P(t,r) gives f(t+r)=f(t)+r for every t≥0. In particular, if r>x, then with t=r−x>0 we have f(r)=f(r−x)+r. Since f(r)=r, this gives f(r−x)=0. But Lemma 13 applied to the positive number r−x gives f(r−x)≥r−x>0, a contradiction. Hence r=x, so f(x)=x. □
Lemma 15. If f(0)=0 and f(x)=x for every x≥0, then for every x<0, f(x)∈{x,−x}.
Proof. By Lemma 1, f(x)2=f(−x)2. Since −x>0 and f(−x)=−x, we obtain f(x)2=x2. Thus f(x)=x or f(x)=−x. It remains to verify the arbitrary choices in the two nonconstant families. For the family with f(x)2=41 for all x, every left-hand input is x2+41≥41, where f equals 21, and hence both sides of the equation equal 21. For the family with f(x)=x for x≥0 and f(x)∈{x,−x} for x<0, one has f(t)2=t2 for every t∈R, and x2+f(y)2=x2+y2≥0. Therefore f(x2+f(y)2)=x2+y2=f(x)2+f(y)2. Finally, f≡0 is immediate. □
Therefore the complete set of solutions is f≡0, f(x)=21 for x≥41,f(x)∈{−21,21} for x<41, and f(x)=x for x≥0,f(x)∈{x,−x} for x<0 as desired. ■