# True or False question about continuous functions

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?

-
What part are you uncertain of? Is $f(x)=1/x$ continuous on $D$? Is $F(D)$ an interval? If you know the answers are "yes" and "no", then you know you have a counterexample. – Chris Eagle Dec 2 '12 at 16:48
Your answer to the first question is wrong, though. $f$ is not defined at $1/2$, so you haven't given a function with domain $[0,1]$ as required. – Chris Eagle Dec 2 '12 at 16:48
What is $D$? If $D$ is connected, then so is $f(D)$, thus $f(D)$ will be an interval. If $D$ is not then you can find a counterexample – Stefan Dec 2 '12 at 16:48
Well, the reason why the image of $\,\frac{1}{x - 0.5}\,$ is not an interval is...because it is not. Someone could argue that the function isn't continuous at $\,0.5\,$ doesn't look sufficient, yet mentioning that the function has a vertical assymptote at $\,x=0.5\,$ is. Now just define $\,f(0.5)=-346.3434\,$ and you\re done. Your answer to second question is correct yet you must give an example, and you found a rathr nice one. – DonAntonio Dec 2 '12 at 16:50
@ChrisEagle Ok, since f is not defined at $f(0.5)$, what else could I use to find something that has an image which is not an interval, but still defined everywhere in $[0,1]$? Maybe it would have something to do with continuity, since the problem does not say "continuous function"? – Alex Dec 2 '12 at 16:55

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