TITLE: Find all functions satisfying $ f \left( m ^ 2 + f ( n ) \right) = f ( m ) ^ 2 + n $, for all $ m , n \in \mathbb N $
QUESTION [5 upvotes]: Find all functions $f:\mathbb{N}\to\mathbb{N}$ such that
$$f(m^{2}+f(n))=f(m)^{2}+n\text {, for all }m,n\in \mathbb N$$
I was initially unable to solve this problem, so I referred to a hint. The hint is as follows:
Let $f(1)=k$. From the given equation, we get $f(m^{2}+k)=1+f(m)^{2}$ and $1+k^{2}=f(1+k)$. Use this to prove that
$$f(f(m))^{2}-f(k)^{2}=m^{2}-1 \ \ \ \ \ \ (*)$$
Taking $m=2$, conclude that $f(k)=1 \ \ \ (*)$. Obtain $f(f(m))=m$ for all $m\in \mathbb{N}$. Use this to prove that $$f(n+1)=f(n)+k^{2} \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ (*)$$
By induction $f(n+1)=f(1)+nk^{2}=k+nk^{2}$. Conclude that $k=1$ and hence $f(n)=n$ for all $n\in \mathbb{N}$
This solution is very unclear to me. I have marked all unclear steps with $(*)$. Please breakdown this solution and provide well explained arguments for the marked steps. Please try to use the same notation I have provided in the solution for ease of understanding. Thanks for all help :)

REPLY [3 votes]: You've been given all of the steps, and just need to creatively figure out why they are true by playing around enough, using what was just discovered/stated.
I've given you additional hints to each $(*)$, and encourage you to think about how to make it true before reading the spoiler.

Let the statement be $P(m, n): f(m^2 + f(n)) = f(m)^2 + n$.
Consider $P(m,1)$ and $P(1,1)$ to get the first 2 equations.
Setting $ m = f(m)$ is the cleanest way to get $ f(f(m))^2$. However, $P(f(m), n), P(f(m),1), P(f(m),k) $ all do not have an easily manipulated LHS. We need to massage it to get another expression of the form $f(m^2 + f(n))$.
$P(f(m), 1+k): f(f(m)^2 + 1 + k^2) = f(f(m))^2 + 1 + k $.


 - $P(k, m^2+k): f( k^2 + 1 + f(m)^2 ) = f(k)^ 2 + m^2 + k$.


Taking the difference gives $f(f(m))^2 - f(k)^2 = m^2 - 1$, which is the first $(*)$.
Taking $m = 2$, $(f(f(2)) - f(k) ) ( f(f(2))+f(k)) = 3 =  1 \times 3$.


 -  which forces $f(f(2)) = 2, f(k) = 1$, which is the second $(*)$.


Hence $ f(f(m))^2 = m^2$, so $f(f(m)) = m$.
$P(k, n): f(k^2+f(n)) =  f(k)^2 + n = 1 + n$.


 - Taking $f$ on both sides, $k^2+f(n) = f \left( f\left( k^2 + f(n)\right)\right)  = f(1+n)$,which is the third $(*)$.


By induction, $f(n) = k+(n-1)k^2$.
Substituting into the original equation, $k + ( m^2 + k +(n-1)k^2 - 1) k^2 = (k+(m-1)k^2)^2 + n $.
Hence $ k = 1$.
Hence $ f(n) = n$.


Note: There are several different ways of approaching this problem.
The key seems to be getting to $f(f(n))=n$.