Extending functions from $(a,b)$ to $[a,b]$.

The function $$ f(x)=\frac1{x(x-1)} $$ is continuous on $(0,1)$ but does not extend to a continuous function on $[0,1]$.


A discussion of extending continuous functions $f: S \subset \mathbb{R}$ to $\overline{S}$ is given in $\S 10.11$ of these notes.

Unfortunately this discussion doesn't contain any examples or applications. Here is one thing that should probably be in there, and which will lead you to see that not every continuous function on $(a,b)$ is uniformly continuous:

Proposition: A uniformly continuous function $f$ defined on a bounded subset $S$ of $\mathbb{R}$ is bounded.

Proof: There is $\delta > 0$ such that for all $x,y \in S$ with $|x-y| \leq \delta$, $|f(x)-f(y)| \leq 1$. Suppose $\sup(S) - \inf(S) = d$ -- this $d$ is called the diameter of $S$ -- and choose a positive integer $N \geq \lceil \frac{d}{\delta} \rceil$. Then we can cover $S$ by $N$ subintervals of length $\delta$, and by the triangle inequality, for all $x,y \in S$, $|f(x)-f(y)| \leq N$. Taking any $x_0 \in S$, we get an upper bound of $|f(x_0)| + \lceil \frac{d}{\delta} \rceil$ for $f$ on $S$.

The above argument is decidedly quantitative, and in fact the bound it gives is sharp, as one sees by considering $f(x) = \frac{1}{\delta}x$ on the interval $[0,d]$ and taking $x_0 = 0$. On the other hand, one can show (more easily!) that if $X$ is any totally bounded metric space and $f: X \rightarrow \mathbb{R}$ is uniformly continuous, then $f$ is bounded. (Note though that the above quantitative argument won't go through in this level of generality: we used some geometric properties of $\mathbb{R}$ related to its "covering dimension". However, it can be pushed through in $\mathbb{R}^N$ with a different bound, depending on $N$.)

And in fact one can show this again as follows: every uniformly continuous function $f$ defined on any metric space extends uniquely to its completion $\tilde{X}$. Further, $X$ is totally bounded iff $\tilde{X}$ is compact, and a continuous function on a compact space is bounded.

All of this should serve to motivate Andrea Mori's example of a continuous function $f: (0,1) \rightarrow \mathbb{R}$ which cannot be continuously extended to $[0,1]$.