I am trying to understand the following:

Theorem: Let $(X,d_X)$ and $Y(d_Y)$ be metric spaces. A function $f:X\rightarrow Y$ is continuous if and only if for every open $U\subset Y$, then $$ f^{-1}(U) = \{x\in X : f(x)\in U\} $$ is open in $X$.

If I want to show that the function $f:[0,1]\cup[2,4]\subset \mathbb R \rightarrow \mathbb R$ defined by $$ f(x) =\begin{cases} 1, & x\in [0,1];\\ 2, & x\in [2,4]. \end{cases} $$ is continuous, then I need to consider any open set $U\subset \mathbb R$ and show that $$f^{-1}(U) = \{x\in [0,1]\cup[2,4] : f(x)\in U\}$$ is open.

I understand that if $1 \notin U$ and $2 \notin U$, then $f^{-1}(U) = \emptyset$. But I don't understand what happens when only $1\in U$, or only $2\in U$, or $1,2\in U$.

If only $1\in U$, then is it correct to say that $f^{-1}(U)=[0,1]$? If only $2\in U$, then is it correct to say that $f^{-1}(U)=[2,4]$? But I am really confused since these are closed intervals. I am lost.

Can someone help me to find $f^{-1}(U)$ for those cases? Any clues or hints will be appreciated.

Thanks in advanced.

  • $\begingroup$ Everything you state is correct. But the fact that $[0,1]$ and $[2,4]$ are closed intervals in $\mathbb{R}$ does not mean they are not open sets in $[0,1] \cup [2,4]$. Are you familiar with the definition of subspace topology? $\endgroup$
    – Woett
    Mar 20, 2022 at 9:44
  • $\begingroup$ $[0,1]$ and $[2,4]$ are open in $[0,1] \cup [2,4]$, since we consider this space to carry the subspace topology inherited from $\mathbb{R}$. For instance, $[0,1] = [0,1] \cap \mathbb{R}$, so it is open. $\endgroup$
    – jasnee
    Mar 20, 2022 at 9:45
  • $\begingroup$ Thanks for that everybody. I totally missed that. I need to review again the concept of subspace topology. $\endgroup$ Mar 20, 2022 at 9:52

1 Answer 1


You are missing the fact that $[1,2]$ and $[2,4]$ are actually open sets in $[0,1]\cup [2,4]$. For example, $[0,1]=\{x\in [0,1]\cup [2,4]: |x-0| <1.5\}$.

So $1 \in U , 2 \notin U$ gives $f^{-1}(U)=[0,1]$ which is open.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .