Example of a continuous function with a discontinuous inverse

The standard example (though not from $\mathbb R^n$ but rather a subset)

$f:[0,2\pi) \to S^1$, $f(x) = (\cos(x),\sin(x))$

$f^{-1}$ is not continuous at $(1,0)$.


Take $f:\mathbb{R} \rightarrow \mathbb{R}^2$ to be a function which performs an eight-shaped figure in the way described here (as $x \rightarrow -\infty$, it tends to the origin, and also as $x \rightarrow \infty$).

For topological reasons, the inverse cannot be continuous.

Note that if $n=m$, then the inverse must be continuous, and this is a result of the Invariance of Domain Theorem. (If $n=m=1$, a direct proof through methods of real analysis can be easily achieved)