3
$\begingroup$

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

3 Answers 3

7

Let $f:\Bbb R\to\Bbb R$ be such that $f(x)=0$ if $x\le 0$ and $f(x)=1$ if $x>0$.

  • 0
    Me too. We all think of the same counterexamples.2012-06-11
  • 0
    Except Asaf, who had to get fancy. :-)2012-06-11
  • 0
    @BrianM.Scott 4 upvotes in the space of 2 minutes, a record to beat :D2012-06-11
  • 0
    @AlexBecker Well that was kinda the obvious one to go for :D :D2012-06-11
6

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.

3

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$.

  • 0
    If we take $K$ to be a compact set which is nowhere dense, but has a positive measure (copies of a fat Cantor set in every $[k,k+1]$, for example) then we can get such function $f$ which is discontinuous on a set of positive measure, which is interesting.2012-06-11
  • 0
    Surely not in every $[k,k+1]$? That set would be unbounded.2012-06-11
  • 0
    @Johan: True. However if we make this union disjoint we have a closed set that is still good enough for our purposes.2012-06-11