I am reading a basic introductory book on topology. It is written that a continuous map f from one topological space X to a second topological space Y is open ( closed ) if it maps open ( closed ) sets from X to open ( closed ) sets in Y. Next the following examples are shown:
$$ f:\ \mathbb{R} \rightarrow \mathbb{R}, x \mapsto x, $$ is closed and open. This is clear, since it maps an interval to the same interval. So open sets will stay open and closed once will be closed.
$$ f:\ \mathbb{R} \rightarrow \mathbb{R}, x \mapsto 0, $$ This is closed but not open. Since everything is mapped to 0 what is always a closed set.If I understand correctly.
$$ f:\ \mathbb{R} \rightarrow \mathbb{R}, x \mapsto \arctan x $$ This is closed but not open.
$$ f:\ \mathbb{R} \rightarrow \mathbb{R}, x \mapsto \left | \arctan x \right | $$ is neither open nor closed.
The last two examples I am not able to understand because to me it would seem that the atan is open and closed, what is definitely wrong since it is written in the book. But why?
Observe that $f(x)=\arctan(x)$ is a homeomorphism (actually a diffeomorphism) between $\mathbb{R}$ and $(-\pi/2, \pi/2)$, because it is continuous (smooth) and has a continuous (smooth) inverse, $f^{-1}(x)=\tan(x)$.
But if you think of it as a map $\mathbb{R}\rightarrow \mathbb{R}$ is not closed since, as observed before it sends $\mathbb{R}$ (closed) to $(-\pi/2, \pi/2)$ which is not closed, otherwise it would disconect $\mathbb{R}$. Now, it is open since as a homeomorphism $\mathbb{R}\rightarrow (-\pi/2, \pi/2)$ it sends open subsets of $\mathbb{R}$ to open subsets of $(-\pi/2, \pi/2)$, which, in turn, are open in $\mathbb{R}$, as $(-\pi/2, \pi/2)$ has the subspace topology. So, $f(x)=\arctan(x)$ is actually open but not closed.
As of $f(x)=|\arctan(x)|$, it is not closed because it sends $\mathbb{R}$ (closed) to $[0,\pi/2)$ (not closed). It is not open by the same reason, it sends $\mathbb{R}$ (open) to $[0,\pi/2)$ (not open).