Suppose $f$ is a continous bijection from compact metric space $X$ onto a metric space $Y$ . Then $f^{-1}$ is continuous mapping of $Y$ onto $X$

I read this theorem in rudin's book:

Suppose $$f$$ is a continous bijection from compact metric space $$X$$ onto a metric space $$Y$$ . Then $$f^{-1}$$ is continuous mapping of $$Y$$ onto $$X$$

I have some questions about hypothesis of the theorem.. Clearly bijection is required for the existence of inverse. But we need compact? Do compact a necessary condition?

I want to see few counterexample,that if $$X$$ is not a compact metric space,then $$f^{-1}$$ is not continuous.

Thanks

• I see an example in rudin mapping [0,$2\pi)$ onto unit circle.please give me some more examples other than this – Cloud JR Oct 6 '18 at 7:41
• $X$ discrete and $Y$ non-discrete so $X= \mathbb{N}$, $0\to 0$ and $n \to \frac1n$. – Henno Brandsma Oct 6 '18 at 7:41
• Here's many examples – Giuseppe Negro Oct 6 '18 at 7:42
• @Henno Brandsma then $Y={\frac{1}{n}:n\in\mathbb N}$ – Cloud JR Oct 6 '18 at 7:47
• And $\{0\}$ too is in $Y$ – Henno Brandsma Oct 6 '18 at 8:42