open vs closed vs continuous between subsets of $\mathbb{R}$ I'm trying to figure out a series of examples. I want them the simplest possible. 



*

*open and closed and continuous: $f: \mathbb{R} \rightarrow \mathbb{R}$,  $f(x) = x$





*continuous but not open and not closed: $f: \mathbb{R} \rightarrow \mathbb{R}$,  $f(x) = \frac{1}{1+x^2}$


*

*because $\mathbb{R}$ which is both open and closed maps to $]0;1]$ which is neither






*continuous and closed but not open: $f: \mathbb{R} \rightarrow \mathbb{R}$,  $f(x) = x^2$


*

*because $\mathbb{R}$ maps to $[0; +\infty[$ which is closed but not open






*continuous and open but not closed: $f: \mathbb{R} \rightarrow \mathbb{R}$,  $f(x) = arctan(x)$


*

*because $\mathbb{R}$ maps to $]-\frac{\pi}{2};\frac{\pi}{2}[$ which is open and not closed






*Not Continuous, Not open, Closed:   $f: \mathbb{R} \rightarrow \mathbb{R}$


$$ 
f(x) = 
\begin{cases}
0,  & \text{if $x \lt 0 $} \\
1+x, & \text{if $x \ge 0$ }
\end{cases}
$$


*

*because images of open neighborhoods of $0$ will not be open





*Not Continuous, Not open, not Closed:
$$ 
f(x) = 
\begin{cases}
x,  & \text{if $x \lt 0 $} \\
1+x, & \text{if $x \ge 0$ }
\end{cases}
$$


*

*because images of open/closed neighborhoods of $0$ will not be open/closed




Question: I'm missing two examples, I have the feeling open functions from $\mathbb{R} \rightarrow \mathbb{R}$, will be continuous and injective ? 
Indeed, assuming $f$ is not left continuous at a single point in $]a;b[$, There will always be some neighborhood of discontinuity such that:


*

*$]a;b[$ maps to $]f(a);x[ \cup [y;f(b)[ $


And continuous open functions have to be injective?  Otherwise an open neighborhood of the singularity need not to be open as in $x \rightarrow x^2$
EDIT: I of course am always using the euclidean topology all along.
 A: Lemma : A continuous function $f : \mathbb{R} \rightarrow \mathbb{R}$ is open if and only if it is injective. 
Proof : 


*

*If $f$ is not injective, then there exists $a, b$ with $$f(a) = f(b) = r$$ for some $r \in \mathbb{R}$ and $a < b$. But since $f$ is continuous $f\big([a, b]\big)$ is compact and connected, and so must be an interval $[c, d]$. If $c = d$, then $f\big((a, b)\big) = {c}$. Otherwise, 
$$[c, d]  ~\supseteq~ f\big((a, b)\big) ~\supseteq~ f\big([a, b]\big) - {r} ~=~ [c, d] - {r}.$$
Both possibilities are not open, so $f$ cannot be open.

*Conversely, if $f$ is injective, then $f$ must be monotonic (i.e. strictly increasing or strictly decreasing). For if $a < b < c$, the intermediate value theorem says that every value between $f(a)$ and $f(b)$ is taken on by some $x \in [a, b]$, so none of them is $f(c)$. Assume that $f(a) < f(b)$. Then $f(c) < f(a)$ or $f(b) < f(c)$. But $f(a)$ can not lie between $f(b)$ and $f(c)$ either, for some $x \in [b, c]$ would have $f(x) = f(a)$ if it did. Hence
$$ f(a) < f(b) < f(c),$$
and the function is increasing. The case for $f(a) > f(b)$ can be shown by applying this case to $-f$. 
Since an injective $f$ is also monotone, 
$$f\big((a, b)\big) ~=~ \begin{cases}\big(f(a), f(b)\big); \\ \big(f(b), f(a)\big).\end{cases}$$
In either case, it is an open set. This is sufficient to show that $f$ is an open function.


Corollary : An open injective function is continuous. 
Proof :  $f^{-1}$ is also an injective function, and is continuous since $f$ is open. Hence $f^{-1}$ is open, and so $f$ is continuous.
Moral : The following 3 cases are impossible: 


*

*$f: \mathbb{R}\rightarrow \mathbb{R}$ continuous, open, not injective;

*$f: \mathbb{R}\rightarrow \mathbb{R}$ continuous, not open, injective;

*$f: \mathbb{R}\rightarrow \mathbb{R}$ not continuous, open, injective.


A function $f : \mathbb{R} \rightarrow \mathbb{R}$ that is open but neither continuous nor closed : See Example 17 on page 168 of "Counterexamples in Analysis" by Bernard R. Gelbaum and John M. H. Olmsted. The construction is described on page 104 (Example 27). 
A: I've just found an example of an open discontinuous function from $\mathbb{R}$ to $\mathbb{R}$, hence answering my question:
http://mathforum.org/library/drmath/view/62395.html
[This is the weird-most I ever met...  I would like to copy the whole answer here in case it disappear from the other forum. Is it ok to to that in term of copyrights and all ?]
