This is an exercise from Mathematical Analysis II by Zorich:(the surface here is the same as manifold, not necessarily 2-dimensional.)
Let $f:\mathbb R^n \to \mathbb R^n$ be a smooth mapping satisfying the condition $f \circ f =f$. a) Show that the set $f(\mathbb R^n)$ is a smooth surface in $\mathbb R^n$. b) By what property of the mapping $f$ is the dimension of this surface determined?
My solution: $$f'(f(x))f'(x)=f'(x)\Rightarrow \forall x\in f(\mathbb R^n),f(x)=x,(f'(x)-I)f'(x)=O.\tag1$$ We can conclude that eigenvalue of $f'(x)$ is $0$ or $1$. Let $P^{-1}(x)f'(x)P(x)=J(0)+\begin{pmatrix}I_r&O\\O&O\end{pmatrix}$where $|P(x)|\neq0$, and according to (1) we can know that $J(0)=O$. Since $tr(f'(x))=rank(f'(x))$ is continous on $f(\mathbb R^n)$, and $f(\mathbb R^n)$ is connected, we can know that $\forall x\in f(\mathbb{R}^n), rank(f(x))\equiv r$.
$\forall x \in \mathbb{R}^n, (P^{-1}(x)\begin{pmatrix}I_r&O\\O&O\end{pmatrix}P(x)-I)f'(x)=O\Rightarrow rank(f'(x))\leq r$
$\forall f(x_0)\in f(\mathbb{R}^n),\ rank (f'(f(x_0)))=r, \forall x\in O(f(x_0)),rank(f'(x))\leq r\Rightarrow \exists \bar O(f(x_0)),\forall x\in \bar O(f(x_0)), rank(f'(x))=r$. According to The rank theroem, we can find $\tilde O(x_0), \tilde O(f(x_0))$ and diffeomorphisms $\phi ,\varphi,f=\phi\circ\pi\circ\varphi^{-1}$ where $ \pi:(u^1,\cdots,u^r,\cdots,u^m)\mapsto(u^1,\cdots,u^r)$, so that the set $f(\mathbb R^n)$ is a smooth surface in $\mathbb R^n$ and the dimension depends on the rank of $f$ on $f(\mathbb R^n)$.
My doubts:
(1) Is my solution above correct? Feel free to point out any mistakes or offer any concise solutions.
(2)Does $f$ have to be a linear mapping with the form $f(x)=P^{-1}\begin{pmatrix}I_r&O\\O&O\end{pmatrix}P$$\cdot$$x$?
(3)If we only assume $f\in C^0(R^m,R^m)$, what properties of $f$ can we get? Is $f(\mathbb R^n)$ still a surface?
Your solution has all the correct ideas but it is written quite sloppily. For example:
Regarding your other questions: