Prove that image of any connected subset of $\Bbb R$ under $f$ is connected. Consider the function $f : \Bbb R \longrightarrow \Bbb R$ defined by $$
f(x) = \left\{
        \begin{array}{ll}
            \sin \frac 1 x & \quad x \gt 0 \\
            0 & \quad x \leq 0
        \end{array}
    \right.
$$
Prove that $f(E)$ is connected for any connected subset $E$ of $\Bbb R.$
What I observed is that $f((-\epsilon, \epsilon)) = [-1,1],$ for any $\epsilon > 0.$ Does it help anyway? I know that connected subsets are precisely intervals.
So for any interval $I$ lying on the left of the origin we have $f(I) = \{0\},$ which is connected. If one of the endpoints of $I$ are on the left of the origin and the other is on the right of the origin then $f(I) = [-1,1],$ which being an interval is again a connected subset of $\Bbb R.$
 A: Your arguments are correct, but do not cover all cases. We shall use your observation in the form that $f((0,\epsilon)) = [-1,1]$ for all $\epsilon > 0$.
As you know $E$ connected means that $E$ is an interval (which may be unbounded to the left and/or right). Define $E_1 = E \cap (-\infty,0]$ and $E_2 = E \cap (0,\infty)$. We have $E = E_1 \cup E_2$. Either both $E_i$ are intervals or one is an interval and the other is empty.

*

*If $E_1 = \emptyset$, then $E = E_2$ and $f(E) = f(E_2)$ is connected because $f \mid_{(0,\infty)}$ is continuous.


*If $E_2 = \emptyset$, then $E = E_1$ and $f(E) = f(E_1)  = \{0\}$ which is connected.


*If both $E_i \ne \emptyset$, then $E_2$ contains some $(0,\epsilon)$. Thus $f(E_2) = [-1,1]$ and therefore $f(E) = f(E_1 \cup E_2) = f(E_1) \cup f(E_2) = \{0\} \cup [-1,1] = [-1,1]$ which is connected.
A: That's a good starting point. It is also true that $f\bigl([0,\varepsilon)\bigr)=[-1,1]$, that $f\bigl([0,\varepsilon]\bigr)=[-1,1]$, that $f\bigl((-\varepsilon,0]\bigr)=[-1,1]$, and that $f\bigl([-\varepsilon,0]\bigr)=[-1,1]$ for every $\varepsilon>0$. Now use the fact that $f$ is continuous on $\Bbb R\setminus\{0\}$ to prove what you want to prove in the remaining types of intervals. Besides, don't forget the intervals of the type, say, $(a,b)$, with $a<0<b$. And, of course, they can also be closed or neither open nor closed.
