Show that function $f$ has a continuous extension to $[a,b]$ iff $f$ is uniformly continuous on $(a,b)$

A continuous function doesn’t necessarily map Cauchy sequences to Cauchy sequences; consider, for instance, the function $f(x)=\frac1x$ on $(0,1)$, which maps the Cauchy sequence $\langle 2^{-n}:n\in\Bbb Z^+\rangle$ to the very non-Cauchy sequence $\langle 2^n:n\in\Bbb Z^+\rangle$. But uniformly continuous functions do map Cauchy sequences to Cauchy sequences. To prove this, suppose that $\langle x_n:n\in\Bbb N\rangle$ in $(a,b)$ is Cauchy, and let $\epsilon>0$. There is a $\delta>0$ such that $|f(x)-f(y)|<\epsilon$ whenever $x,y\in(a,b)$ and $|x-y|<\delta$, and there is an $m\in\Bbb N$ such that $|x_k-x_n|<\delta$ whenever $k,n\ge m$, so ... ?

Now let $\sigma=\langle x_n:n\in\Bbb N\rangle$ be a sequence in $(a,b)$ converging to $a$. Clearly $\sigma$ is Cauchy, so by the hint $\langle f(x_n):n\in\Bbb N\rangle$ is Cauchy. $\Bbb R$ is complete, so $\langle f(x_n):n\in\Bbb N\rangle$ converges to some $c\in\Bbb R$; this $c$ is the natural candidate for $g(a)$. In similar fashion you can find a natural candidate $d$ for $g(b)$, and all that remains is to show that the function

$$g:[a,b]\to\Bbb R:x\mapsto\begin{cases} c,&\text{if }x=a\\ f(x),&\text{if }x\in(a,b)\\ d,&\text{if }x=b \end{cases}$$

is continuous at $a$ and $b$.


Much more is true: if $D$ is a dense subset of a metric space $X$, $Y$ is a complete metric space and $f\colon D\to Y$ is uniformly continuous, then $f$ admits a (unique) extension to a (uniformly) continuous map $\hat{f}\colon X\to Y$.

This is a key result in the theory of metric spaces, which has several applications. For example, a continuous linear map from a dense subspace of a Banach space $X$ to a Banach space $Y$ can be extended to a continuous linear map from $X$ to $Y$; so, for instance, one can define an element of the topological dual of $X$ by just defining it on a dense subspace.

The proof consists, as in Brian M. Scott's answer, in noting that if $f\colon D\to Y$ is uniformly continuous, then it maps Cauchy sequences to Cauchy sequences. So the extension is naturally defined and all it's needed is to show that the extension is continuous.

So these are the steps:

  1. If $x\in X$, there is a sequence $(x_n)$ in $D$ converging to $x$; then $(f(x_n))$ is a Cauchy sequence in $Y$ and so it converges to some point $y$.

  2. If $(x'_n)$ is another sequence in $D$ converging to $x$, then both $(f(x_n))$ and $(f(x'_n))$ converge to $y$.

  3. We can define $\hat{f}(x)=y$ because of the preceding results.

  4. If $x\in D$, then $\hat{f}(x)=f(x)$, by considering the constant sequence.

  5. $\hat{f}$ is continuous at $x$.

Uniqueness is obvious, because two extensions must coincide on a dense subset. Uniform continuity of $\hat{f}$ is also easy to show.