I want to find all functions $f:\mathbb{Z}\rightarrow\mathbb{Z}$ such that for all integers $n,m\in\mathbb{Z}$,
$$f(n^2+m)=f(n+m^2).$$
Obviously, any constant function is a solution and probably there are not any further solutions (I am not completely sure about that though). Unfortunately, I do not know how to solve the above problem and would like to ask you to help me.
Obviously, the function has to be an even function (put e.g. $m=0$). I tried some more substitutions to obtain further information. E.g. putting $n=\pm 1$ gives $f(m^2-1)=f(m^2+1)$ for all $m\in\mathbb{Z}$. etc.
I would appreciate any help.
The answer is$$ f(x) = \begin{cases} a; & x \text{ odd}\\ b; & x \text{ even} \end{cases}, $$ where $a, b$ are constants.
First to verify that such $f$'s indeed satisfy the condition. For any $m, n \in \mathbb{Z}$, because $m^2 \equiv m \pmod{2}$ and $n^2 \equiv n \pmod{2}$, then either $m^2 + n$ and $m + n^2$ are both odd or both even. Thus either $f(m^2 + n) = a = f(m + n^2)$ or $f(m^2 + n) = b = f(m + n^2)$.
Next, suppose $f$ is any function satisfying the condition. For any $x \in \mathbb{Z}$, take $(m, n) = (x, 0)$, then $f(x) = f(x^2)$, which also implies $f(-x) = f(x^2) = f(x)$. Now take $(m, n) = (x - 1, 1)$, then $f(x) = f(x^2 - 2x + 2)$. Take $(m, n) = (-x + 1, 1)$, then $f(-x + 2) = f(x^2 - 2x + 2)$. Therefore,$$ f(x) = f(-x + 2) = f(x - 2). \quad \forall x \in \mathbb{Z} $$