Show that $A=\{x\in X\mid a\leq f(x)\leq b\:;\;a,b\in\mathbb{R}\}$ is closed if $f:X\to \mathbb R$ is continuous. Let $X$ be a set. Suppose that $f:X\to\mathbb{R}$ is a continuous function and let $A=\{x\in X\mid a\leq f(x)\leq b\:;\;a,b\in\mathbb{R}\}$. Is $A$ closed, open, clopen or none?
So I started by saying that $f(A)=\{p=f(x)\mid a\leq p\leq b\;\text{for some}\;x\in X\}$ but I can't figure out if the set is closed.
 A: By (some variant of) definition, a map $f\colon X\to Y$ between topological spaces is continuous iff $f^{-1}(S)$ is a closed subset of $X$ whenever $S$ is a closed subset of $Y$. The interval $[a,b]$ is a closed subset of $\mathbb R$.
A: It is closed. 
The simplest way to see it is the following: Let $\{x_n\}_{n\in\mathbb N}\subset\{x:a\le f(x)\le b\}$, with $x_n\to x_0$. Then, 
$$
a\le f(x_n)\le b, \quad\text{for all $n$},
$$
and as $f$ is continuous, $f(x_n)\to f(x_0)$, which implies that
$$
a\le f(x_0)\le b.
$$
Thus $x_0\in\{x:a\le f(x)\le b\}$, and hence $\{x:a\le f(x)\le b\}$ is closed.
A: If $f$ is continuous then $f^{-1}(A)$ is closed if $A \subset \mathbb{R}$ is closed. You have that $A$ is closed in $\mathbb{R}$. Then it follows. 
To show that $A$ is closed in $\mathbb{R}$, take any $x \in \overline{A}$ then there exists $\lbrace a_n\rbrace$ a sequence with elements in $A$ such that $\lim a_n = x$. As $f$ is continuous you have that $\lim f(a_n) = f(x)$ and
$$a\leq f(a_n) \leq b \Rightarrow a \leq \lim f(a_n) \leq b \Rightarrow a \leq f(x) \leq b $$
Then $x \in A$ so $\overline{A} = A$. 
A: Do you know that $f: X \to Y$ is continuous iff for any open set $B\subset Y$, $f^{-1}(B)$ is also open. This is also the definition of continuity.
So notice that $[a,b]$ is closed, so $A=X\setminus f^{-1}(Y\setminus [a,b])$ is closed.
