An example of a complete metric space $X$ and a function $f: X \to X$ which is a continuous bijection such that $f^{-1}$ is not continuous. Give an example of a complete metric space $X$ and a function $f: X \to X$ which is a continuous bijection such that $f^{-1}$ is not continuous. This is an offshoot of the following: Finding an (easy) example of a bijective continuous self mapping whose inverse is not continuous
There are examples where the domain and range are not the same and examples where completeness is not a requirement. Of course, OMT shows that we cannot take  a linear map between Banach spaces.  I tried some non-linear maps on Banach spaces but I didn't succeed in finding an example. Thank you for your time. 
 A: My attempt is to find one of  the simplest examples.
Let $X=\{0\}\cup \{2,3,4...\} \cup \{\frac 1 n: n \in \mathbb N \}$ with the usual metric from $\mathbb R$.
This is a closed subset of $\mathbb R$ and hence it is complete.
Let $f(0)=0, f(\frac 1  n)=\frac  1 {2n}, f(2n)=\frac 1 {2n-1}$ and $f(2n+1)=n+1$ for all positive integers $n$. Then $f$ is a bijection. The only limit point of the space is $0$ and $f(x) \to 0$ as $x \to 0$ , so $f$ is continuous.
Now, $f(2n)=\frac 1 {2n-1} \to 0=f(0)$ but $2n$ does not tend to $0$ so $f^{-1}$ is not continuous.
A: 
If we let $M$ be the union of countably infinitely many lines and lollipops in the plane, as shown above, with the induced Euclidean metric, then I claim that there exists a bijection which satisfies the conditions.
(the lines are infinitely long, and the lollipops extend infinitely off to the right).
Indeed, it suffices to show that there is such a bijection from a line to a lollipop -- if we label the lines $\ell_1,\ell_2,\ldots$ and the lollipops $\mathcal l_1,\mathcal l_2,l\ldots$, then it's trivial to find a bijection $f:\ell_{i+1}\to\ell_i$ for $i\ge1$ and similarly for the lollipops. To find a bijection with no continuous inverse, we just "wrap" the line around the lollipop as shown below:

Note that the endpoint of the line is open (so it's homeomorphic to "half" of a line), and thus this map is continuous, but the inverse isn't at that intersection.
If you further require this space to be connected, we can trivially draw a vertical line through all the lines and lollipops to the right, and move this line up with everything else.
A: One can construct also examples using nonlinear maps between Banach spaces. In fact any infinite-dimensional space will do. I copied this from my (edited) answer in Easy example of a bijective continuous self mapping whose inverse is discontinuous.
First we note that we cannot have any such counterexample in any finite-dimensional normed space. Indeed, they are all homeomorphic to some $\mathbb{R}^n$ and the invariance of the domain theorem (https://en.wikipedia.org/wiki/Invariance_of_domain) tells us that any continuous, injective map $f: \mathbb{R}^n \rightarrow \mathbb{R}^n$ is a homeomorphism on its image.
In
Van Mill, J. (1987). Domain Invariance in Infinite-Dimensional Linear Spaces. Proceedings of the American Mathematical Society, 101(1), 173-180. doi:10.2307/2046571
it is claimed that we can construct such an example in any infinite-dimensional normed space $X$. The only thing one needs to construct is a continuous map $\lambda : S \rightarrow (0,1]$ with $\inf_{x\in S} \lambda(x) =0$, where $S$ is the unit sphere in $X$. Then one considers the map
$$f: X \rightarrow X, \ f(x) = \begin{cases} \lambda\left( \frac{x}{\Vert x \Vert} \right) x,& x\neq 0, \\
0,& x=0.
\end{cases}$$
The function $f$ is clearly bijective and continuous (as $\lambda$ is continuous and does not vanish). To see that it is not a homeomorphism we show that it is not an open map. This follows from the fact that $f$ preserves all halfrays starting in zero and that by construction that we find halfrays that shrink as much as we like (as $\inf_{x\in S} \lambda(x) =0$). So for any bounded set $A\subseteq X$ we have $0\notin \operatorname{int}(f(A))$ and thus $f$ is not an open map and hence not a homeomorphism.
We are left to show that such a $\lambda$ really exists. As we are in infinite-dimensions, by the Riesz lemma (https://en.wikipedia.org/wiki/Riesz%27s_lemma) there exists a sequence $(x_n)_{n\in \mathbb{N}} \subseteq S$ such that $\Vert x_n - x_m \Vert \geq \frac{1}{2}$ for all $n\neq m$. Now we make them slightly bigger, i.e. we define $y_n:= \left( 1+ \frac{1}{n+4} \right) x_n$. Then we have that $dist(S, y_n)=1/(n+1)$ and for $n\neq m$
$$\Vert y_n - y_m \Vert \geq \Vert x_n - x_m \Vert - \frac{1}{n+4} - \frac{1}{m+1} \geq \frac{1}{2} - \frac{1}{4} - \frac{1}{5} = \frac{1}{20}. $$
Hence, $Y:=\{ y_n \ : n\in \mathbb{N} \}$ is discrete and hence closed. Now we define (inspired by the proof of the Urysohn lemma)
$$ g: S \rightarrow [0,\infty), \ g(x) := dist(x,Y). $$
Hence, $g$ is continuous and $g(x) = 0$ iff $x\in \overline{Y}=Y$. This shows that $g$ is continuous and never vanishes. Furthermore, we have
$$g(x) = dist(x,Y) \leq \Vert x - y_0 \Vert \leq \Vert x \Vert + \Vert y_0 \Vert  
\leq 1 + \left( 1 + \frac{1}{4}\right) = \frac{9}{4}.  $$
Thus, we may pick $\lambda = \frac{4}{9} g$.
