TITLE: Find all functions $f:\mathbb N_0\to \mathbb N_0$ such that $f(a^2+b^2)=f(a)^2+f(b)^2$
QUESTION [9 upvotes]: I think the answer is that there are only 2 such functions: the zero function and the identity function, but I'm not able to prove it.
A few findings:

$f(0)=0$ and thus $f(a^2)=f(a)^2$.

If $f(1)=0$, then $f(2^n)=0$ for all $n\in \mathbb N_0$; if $f(1)=1$, then $f(2^n)=2^n$ for all $n\in \mathcal N_0$ (can be proven by PMI).

For any functions satisfying the condition, say $f,g$, $f\circ g$ also satisfies the condition.


Source of this problem: https://www2.math.binghamton.edu/p/pow/problem2f20

REPLY [4 votes]: I found a much simpler proof, heavily based on and inspired by the ideas of Hagen von Eitzen's solution. For the sake of completeness, we first note that $f(0) = 2f(0)^2$ and because $1 \neq 2f(0)$, we must have $f(0) = 0$. Next we find $f(1)^2 = f(1)$ and so $f(1) \in \{ 0,1 \}$. For convenience, denote $u = f(1)$. More generally, we have that $f(a^2) = f(a)^2$.
We proceed by noting that $f(2) = 2u^2 = 2u$ and so $f(4) = f(2)^2 = 4u$. Further, observe that $f(5) = f(1)^2 + f(2)^2 = 5u$. Next we note that
$f(3)^2 + f(4)^2 = f(25) = f(5)^2.$ We conclude that $f(3) = 3u$ also. Lastly, we note that $f(8) = f(2)^2 + f(2)^2 = 8u$ and $f(10) = f(3)^2 + f(1)^2 = 10u,$ so that from
$f(6)^2 + f(8)^2 = f(100) = f(10)^2$ we find that $f(6) = 6u$ too.
We will now prove with induction that $f(n) = nu$ for all non-negative integers $n$. Suppose that for some integer $n > 6$ we have shown that $f(k) = ku$ for all $k < n$. If $n$ is odd, write $n = 2m+1$ for some $m > 2$. Then the equality
$$
(2m+1)^2 + (m-2)^2 = (2m-1)^2 + (m+2)^2
$$
implies via the functional equation that
$$
f(2m+1)^2 + f(m-2)^2 = f(2m-1)^2 + f(m+2)^2
$$
Since all of $m-2$, $2m-1$ and $m+2$ are smaller than $2m+1$, the result for $n = 2m+1$ follows by induction. Similarly, for even $n$, we write $n = 2m+2$ for some $m > 2$ to find that
$$
(2m+2)^2 + (m-4)^2 = (2m-2)^2 + (m+4)^2
$$
implies via the functional equation that
$$
f(2m+2)^2 + f(|m-4|)^2 = f(2m-2)^2 + f(m+4)^2.
$$
Therefore the induction hypothesis ensures that the result also holds for $n = 2m+2$, as desired.