# What are good examples for functions that are semi-continuous but not left/right continuous and vice versa?

I am looking for good simple examples that capture the difference in definitions between semi-continuity and continuity from the left/right.

I am certainly able to construct examples and wikipedia also lists some:

http://en.wikipedia.org/wiki/Semi-continuity

But the given examples are semi-continuous by the trivial fact of having a maximum at the point in question.

Are there examples for functions that are upper semicontinuous, but not left/right continuous and for functions that are left continuous but not upper/lower semicontinuous that capture at the same time a larger part of the subtleties of the definitions and are given by simple expressions?

-

Take any two continuous functions $f$ and $g$ from $\mathbb R$ to $\mathbb R$, such that $f(x) - g(x) > \epsilon > 0$ for all $x \in \mathbb R$, and define

$$h(x) = \begin{cases} f(x) & \text{if } x \in \mathbb Q, \\ g(x) & \text{if } x \in \mathbb R \setminus \mathbb Q. \end{cases}$$

Then, if I understand the definition correctly, $h$ will be upper semicontinuous at all rational points and lower semicontinuous at all irrational points, while being neither left nor right continuous anywhere. Or course, the same construction works equally well with any partition of $\mathbb R$ into dense subsets.

However, reading between the lines, I guess what you really want is an example of a function which is (WLOG) upper semicontinuous everywhere, is neither left nor right continuous as some point $x_0$, and does not have a local extremum at $x_0$. The second Wikipedia example (involving a two-sided topologist's sine curve) almost works, though, and we can easily tweak it a bit to get

$$f(x) = \begin{cases} (x^2+1) \sin (1/x) & \text{if } x \ne 0, \\ 1 & \text{if } x = 0. \end{cases}$$

This function should satisfy the requirements given above for $x_0 = 0$.

-