Refer to the main equation as E(a,b). E(0,b) reads as fb2(b)=bf(b). For b=−1 this gives f(−1)=0. Now E(a,−1) reads as fa2+1(a−1)=af(a)=fa2(a). For x∈Z define the orbit of x by O(x)={x,f(x),f(f(x)),…}⊆Z. We see that the orbits O(a−1) and O(a) differ by finitely many terms. Hence, any two orbits differ by finitely many terms. Therefore, either all orbits are finite or all orbits are infinite. Case 1: All orbits are finite. Then O(0) is finite. Using E(a,−a) we get a(f(a)−f(−a))=af(a)−af(−a)=f2a2(0)∈O(0) For ∣a∣>maxz∈O(0)∣z∣, this yields f(a)=f(−a) and f2a2(0)=0. Therefore, the sequence (fk(0):k=0,1,…) is purely periodic with a minimal period T which divides 2a2. Analogously, T divides 2(a+1)2, therefore, T∣gcd(2a2,2(a+1)2)=2, i.e., f(f(0))=0 and a(f(a)−f(−a))=f2a2(0)=0 for all a. Thus, f(a)=f(−a) for all a=0 in particular, f(1)=f(−1)=0 Next, for each n∈Z, by E(n,1−n) we get nf(n)+(1−n)f(1−n)=fn2+(1−n)2(1)=f2n2−2n(0)=0 Assume that there exists some m=0 such that f(m)=0. Choose such an m for which ∣m∣ is minimal possible. Then ∣m∣>1 due to (ϕ);f(∣m∣)=0 due to ( ϕ); and f(1−∣m∣)=0 due to (Ω) for n=∣m∣. This contradicts to the minimality assumption. So, f(n)=0 for n=0. Finally, f(0)=f3(0)=f4(2)=2f(2)=0. Clearly, the function f(x)≡0 satisfies the problem condition, which provides the first of the two answers. Case 2: All orbits are infinite. Since the orbits O(a) and O(a−1) differ by finitely many terms for all a∈Z, each two orbits O(a) and O(b) have infinitely many common terms for arbitrary a,b∈Z. For a minute, fix any a,b∈Z. We claim that all pairs (n,m) of nonnegative integers such that fn(a)=fm(b) have the same difference n−m. Arguing indirectly, we have fn(a)=fm(b) and fp(a)=fq(b) with, say, n−m>p−q, then fp+m+k(b)=fp+n+k(a)=fq+n+k(b), for all nonnegative integers k. This means that fℓ+(n−m)−(p−q)(b)=fℓ(b) for all sufficiently large ℓ, i.e., that the sequence (fn(b)) is eventually periodic, so O(b) is finite, which is impossible. Now, for every a,b∈Z, denote the common difference n−m defined above by X(a,b). We have X(a−1,a)=1 by (1). Trivially, X(a,b)+X(b,c)=X(a,c), as if fn(a)=fm(b) and fp(b)=fq(c), then fp+n(a)=fp+m(b)=fq+m(c). These two properties imply that X(a,b)=b−a for all a,b∈Z. But (1) yields fa2+1(f(a−1))=fa2(f(a)), so 1=X(f(a−1),f(a))=f(a)−f(a−1) for all a∈Z Recalling that f(−1)=0, we conclude by (two-sided) induction on x that f(x)=x+1 for all x∈Z. Finally, the obtained function also satisfies the assumption. Indeed, fn(x)=x+n for all n⩾0, so fa2+b2(a+b)=a+b+a2+b2=af(a)+bf(b) Comment. There are many possible variations of the solution above, but it seems that finiteness of orbits seems to be a crucial distinction in all solutions. However, the case distinction could be made in different ways; in particular, there exist some versions of Case 1 which work whenever there is at least one finite orbit. We believe that Case 2 is conceptually harder than Case 1.