Let me first state the definition of semi-continuous function.
Let $X$ be a space and $f : X \rightarrow \mathbb{R}$ a real-valued function on $X$. Then $f$ is upper semi-continuous if $f^{-1} (-\infty, a)$ is open for each $a$ in $\mathbb{R}$; $f$ is lower semi-continous if $f^{-1}(a, \infty)$ is open for each $a$ in $\mathbb{R}$.
and I know that
A function $f$ is continuous iff it is both upper and lower semi-continuous.
First I want to prove \begin{align} f(x) = \begin{cases} \frac{1}{x} \quad & x<0, \\ 0 \quad & x=0, \\ -\frac{1}{x} & x>0. \end{cases} \end{align} is upper semi-continuous. [From analysis, since $\lim_{x\rightarrow 0} f(x) = -\infty < f(0)=0$, I know this function $f$ is upper semi-continuous]
From the topological definition I have \begin{align} f^{-1} (-\infty, a) = \begin{cases} (-\frac{1}{|a|}, 0) \cup (0, \frac{1}{|a|}) \quad & a<0 \\ (-\infty, 0) \cup (0, \infty) \quad & a=0 \\ (-\infty, 0) \cup \{0\} \cup (0, \infty) = \mathbb{R} & a \geq 0 \end{cases} \end{align} so any case the inverse image is open so $f$ is upper semi- continuous.
But
\begin{align} f^{-1} ( a, \infty) = \begin{cases} \phi \quad & a \geq 0 \\ (-\infty, -\frac{1}{|a|}) \cup \{0\} \cup (\frac{1}{|a|}, \infty) & a <0 \end{cases} \end{align} this seems also open for arbitrary $a\in \mathbb{R}$...
However this cannot be true since $f$ is not continuous. [$f(0) \neq \lim_{x\rightarrow 0} f(x)$.] What's wrong with my approach?
$(-\infty, -\frac{1}{|a|}) \cup \{0\} \cup (\frac{1}{|a|}, \infty)$ is not open.