[Math] True or False question about continuous functions

calculuscontinuity

I am working through my study guide for my calculus class for the test we're having tomorrow. There are two problems that I'm not completely sure about.

For each of the following statements, determine whether it is true or false and justify your answer.

  1. For any function $f:\left[0,1\right]\rightarrow\mathbb{R}$, its image $f\left(\left[0,1\right]\right)$ is an interval.
  2. For any continuous function $f:D\rightarrow\mathbb{R}$, its image $f\left(D\right)$ is an interval.

For the first one, I said:

False. Let $f(x)=\frac{1}{x-\frac{1}{2}}$, $f$ is not continuous at $x=\frac{1}{2}$, and thus the image is not an interval.

For the second one, I said:

False. If $D$ is not an interval.

For the first one, I am decently confident that my answer is correct. I would just like to know what you think, if it is sufficient enough.

However, for the second one, I don't know where to go for the second one. The professor would like an example, so maybe something like $D=(-\infty,0)\cup(0,\infty)$ and $f(x)=\frac{1}{x}$? Because, then the image of $f(D)$ would not include 0, and thus not be an interval. Would that work as an example?

Best Answer

Here are some easy counterexamples:

  1. Define $$f(x) := \begin{cases} 0 & x \in \left[0,\frac{1}{2}\right] \\ 1 & x \in \left(\frac{1}{2},1 \right] \end{cases}$$ Then $f([0,1]) = \{0,1\}$ and this is obviously no interval.
  2. You already mentioned $g(x) := \frac{1}{x}$ for $x \in D:=(-\infty,0) \cup (0,\infty)$. That works. Another (maybe easier) one would be $$h(x) := x \qquad \qquad D=:[0,1] \cup [2,3]$$ Then $h(D)=[0,1] \cup [2,3]$ and this is -again- no interval (but $h$ is continuous).