I know that the condition that $f(X)$ is compact if $X$ is compact should not be sufficient to say that $f$ is continuous, but I can't come up with an example of such discontinuous $f$. What is it?
Thanks
I know that the condition that $f(X)$ is compact if $X$ is compact should not be sufficient to say that $f$ is continuous, but I can't come up with an example of such discontinuous $f$. What is it?
Thanks
Let $f:\Bbb R\to\Bbb R$ be such that $f(x)=0$ if $x\le 0$ and $f(x)=1$ if $x>0$.
You can take $f\colon\mathbb {R\to R}$ to be $f(x)=\begin{cases}0 & x\in\mathbb Q\\ 1 & x\notin\mathbb Q\end{cases}$
This function is discontinuous everywhere but its image is a finite set and therefore compact.
More generally, if you let $K$ be any compact subset of $\mathbb R$ with at least two points, pick some $x_0\in K$ and let $f:\mathbb R\to\mathbb R$ defined by $f(x)=\begin{cases}x & x\in K\\ x_0 & x\notin K\end{cases}$ then $f$ is a discontinuous function with image $K$.