Tutorials › Real Analysis › Uniform Continuity and Compactness

Uniform Continuity · Tutorial 373 of 1000

Uniform Continuity and Compactness

Learn how uniform continuity supports extension from a dense subset, why the extension is unique, and why compact closure alone does not guarantee uniform continuity.

Intermediate 8 min read

What You'll Learn

  • Relate compactness to uniform continuity without confusing sufficient conditions with necessary ones
  • Construct an extension from limits of function values along approximating sequences
  • Prove that the extension is well-defined and uniformly continuous
  • Show why density makes a continuous extension unique
  • Test the role of compactness using a continuous function that is not uniformly continuous

Compactness and Uniform Control

The Heine-Cantor Theorem and its proof establish a central link: a continuous function on a compact subset of the real line is uniformly continuous. Compactness lets local continuity controls combine into one control that works across the whole domain. This tutorial develops a related consequence: a uniformly continuous function on a dense subset of a compact set can be extended to the entire set.

This extension principle is useful when a function is initially defined only on a dense collection of points, such as the rationals in an interval. Uniform continuity ensures that function values along approximations to a missing point settle toward one well-defined value. Compactness places the closure in a familiar setting, while density ensures that the extension, if continuous, is unique.

The distinction between continuity and uniform continuity matters here. Continuity on a noncompact domain does not guarantee that the values along every sequence approaching a missing point have a common limit. The theorem below uses uniform continuity to control all pairs of sufficiently close inputs, regardless of where they lie in the domain.

Extending from a Dense Subset

Theorem (Uniform Extension to a Compact Closure): Let \(E\subseteq\mathbb{R}\), and suppose its closure \(K=\overline{E}\) is compact. Let \(f:E\to\mathbb{R}\) be uniformly continuous. Then there is a unique continuous function \(F:K\to\mathbb{R}\) such that \(F(x)=f(x)\) for every \(x\in E\). In fact, \(F\) is uniformly continuous on \(K\).

Proof. If \(E\) is empty, then \(K\) is empty, and the unique function from \(K\) to \(\mathbb{R}\) has the required properties. Suppose henceforth that \(E\) is nonempty.

Fix \(a\in K\). Since \(a\) belongs to the closure of \(E\), for each positive integer \(n\) we can choose \(x_n\in E\) such that \(|x_n-a|<1/n\). Thus \(x_n\to a\). We first show that \((f(x_n))\) is a Cauchy sequence. Given \(\varepsilon>0\), uniform continuity of \(f\) gives \(\delta>0\) such that, for \(u,v\in E\),

$$ |u-v|<\delta\quad\Longrightarrow\quad |f(u)-f(v)|<\varepsilon. $$

Because \(x_n\to a\), there is an index \(N\) such that \(|x_n-a|<\delta/2\) whenever \(n\geq N\). If \(m,n\geq N\), then

$$ |x_n-x_m| \leq |x_n-a|+|x_m-a| <\delta. $$

It follows that \(|f(x_n)-f(x_m)|<\varepsilon\), so \((f(x_n))\) is Cauchy. Completeness of \(\mathbb{R}\) gives a limit. Define \(F(a)\) to be this limit.

We must show that this value does not depend on the approximating sequence. Suppose \(y_n\in E\) also satisfies \(y_n\to a\). Given \(\varepsilon>0\), choose \(\delta>0\) from uniform continuity so that inputs less than \(\delta\) apart have function values less than \(\varepsilon\) apart. For all sufficiently large \(n\), both \(|x_n-a|<\delta/3\) and \(|y_n-a|<\delta/3\). Therefore

$$ |x_n-y_n| \leq |x_n-a|+|y_n-a| <\frac{2\delta}{3}<\delta, $$

and hence \(|f(x_n)-f(y_n)|<\varepsilon\). The two sequences of function values have limits, and their difference tends to zero. Their limits are equal. Thus \(F(a)\) is well-defined.

If \(a\in E\), the constant sequence \(x_n=a\) is an allowed sequence of points in \(E\) approaching \(a\). It gives \(F(a)=f(a)\), so \(F\) extends \(f\).

Next we prove uniform continuity of \(F\). Fix \(\varepsilon>0\). By uniform continuity of \(f\), choose \(\delta>0\) such that

$$ u,v\in E,\quad |u-v|<\delta \quad\Longrightarrow\quad |f(u)-f(v)|<\frac{\varepsilon}{2}. $$

Let \(a,b\in K\) satisfy \(|a-b|<\delta/3\). Choose sequences \(x_n,y_n\in E\) with \(x_n\to a\) and \(y_n\to b\). For all sufficiently large \(n\), both \(|x_n-a|<\delta/3\) and \(|y_n-b|<\delta/3\). The triangle inequality then gives

$$ |x_n-y_n| \leq |x_n-a|+|a-b|+|b-y_n| <\frac{\delta}{3}+\frac{\delta}{3}+\frac{\delta}{3} =\delta. $$

Consequently, \(|f(x_n)-f(y_n)|<\varepsilon/2\) for all sufficiently large \(n\). By the definition of \(F\), \(f(x_n)\to F(a)\) and \(f(y_n)\to F(b)\). Taking limits gives \(|F(a)-F(b)|\leq\varepsilon/2<\varepsilon\). Thus the single choice \(\delta/3\) works for all \(a,b\in K\), and \(F\) is uniformly continuous.

Finally, suppose \(G:K\to\mathbb{R}\) is another continuous extension of \(f\). Fix \(a\in K\) and choose \(x_n\in E\) with \(x_n\to a\). Continuity of \(G\) gives \(G(x_n)\to G(a)\), while \(G(x_n)=f(x_n)\to F(a)\). Limits in \(\mathbb{R}\) are unique, so \(G(a)=F(a)\). This holds for every \(a\in K\), proving uniqueness. \(\square\)

The construction assigns a value at \(a\) by taking a limit of values along points of \(E\) that approach \(a\). Uniform continuity does two jobs: it makes those values Cauchy, and it makes the resulting limit independent of the chosen approximating sequence. The proof of uniform continuity of \(F\) then carries the same input scale control from \(E\) to its closure.

Worked Examples

Worked Example: Extending a Function from the Rationals

Let \(E=\mathbb{Q}\cap[0,1]\), and define \(f(x)=x^2+x\) for \(x\in E\). The closure of \(E\) is \(K=[0,1]\), which is compact. For \(x,y\in E\),

$$ |f(x)-f(y)| =|x^2-y^2+x-y| =|x-y|\,|x+y+1| \leq 3|x-y|, $$

since \(0\leq x,y\leq1\), so \(1\leq x+y+1\leq3\). Given \(\varepsilon>0\), choosing \(\delta=\varepsilon/3\) proves uniform continuity of \(f\) on \(E\). The theorem therefore gives a unique continuous extension to \([0,1]\). In this case the extension is \(F(x)=x^2+x\): it agrees with \(f\) on the rationals, and it is continuous on the whole interval.

For example, rational numbers \(x_n\) approaching \(1/2\) have function values \(x_n^2+x_n\) approaching \(1/4+1/2=3/4\). The extension must assign that value at \(1/2\), regardless of which rational sequence is used.

Worked Example: Filling a Missing Point

Let \(E=[0,1]\setminus\{1/2\}\), and define \(f(x)=(x-1/2)^2+2\) on \(E\). For \(x,y\in E\),

$$ |f(x)-f(y)| =|(x-y)(x+y-1)| \leq |x-y|, $$

because \(x,y\in[0,1]\) implies \(|x+y-1|\leq1\). Thus \(f\) is uniformly continuous, and its closure is the compact set \([0,1]\). The unique continuous extension is

$$ F(x)=(x-1/2)^2+2\qquad (x\in[0,1]). $$

In particular, \(F(1/2)=2\). To see why that value is forced, take any sequence \(x_n\in E\) tending to \(1/2\). Then \((x_n-1/2)^2\to0\), so \(f(x_n)\to2\). The missing point receives the same limiting value no matter how it is approached within \(E\).

Worked Example: Compact Closure Does Not Ensure Uniform Continuity

Consider \(E=(0,1]\), whose closure \([0,1]\) is compact, and let \(f(x)=\sin(1/x)\). This function is continuous at every point of its domain, but it is not uniformly continuous. For positive integers \(n\), set

$$ x_n=\frac{1}{\pi/2+2\pi n}, \qquad y_n=\frac{1}{3\pi/2+2\pi n}. $$

For \(n\geq1\), both points belong to \((0,1]\), and \(x_n\to0\) and \(y_n\to0\). Hence \(|x_n-y_n|\to0\). Yet direct substitution gives

$$ f(x_n)=\sin(\pi/2+2\pi n)=1, \qquad f(y_n)=\sin(3\pi/2+2\pi n)=-1. $$

Therefore \(|f(x_n)-f(y_n)|=2\) for every \(n\). This contradicts the sequential criterion for uniform continuity, so \(f\) is not uniformly continuous. In particular, it cannot have a continuous extension to \([0,1]\): such an extension would have to be continuous, and hence uniformly continuous by the Heine-Cantor Theorem, while agreeing with \(f\) on \((0,1]\).

What Compactness Does—and Does Not—Say

The examples separate two useful statements. First, Heine-Cantor says that continuity on a compact domain implies uniform continuity. Second, the extension theorem says that uniform continuity on a dense subset of a compact set allows the function to extend continuously and uniformly continuously to the closure. Neither statement says that compactness of the closure alone makes a continuous function on a nonclosed subset uniformly continuous. The oscillating example shows why that inference would be false.

The extension theorem also clarifies the role of density. The values on a dense set leave no freedom to choose a different continuous extension: every point of the closure is approached by points where the function is already prescribed. By contrast, if a point is not in the closure, values there are not constrained by this argument.

The proof uses the completeness of \(\mathbb{R}\) to obtain limits of Cauchy sequences of function values. Compactness of the closure is a natural setting for the result and is especially useful alongside Heine-Cantor. In fact, the sequence construction works whenever the closure is a closed subset of \(\mathbb{R}\); closedness makes that closure complete. In applications involving endpoints, the same reasoning explains how uniform continuity can supply a value at a point omitted from the original domain.

Check Your Understanding

Use the extension theorem and examples above to answer the following questions.

  1. Why does uniform continuity make the function values along a sequence approaching a point in the closure into a Cauchy sequence?
  2. How does the proof show that two different sequences from \(E\) approaching the same point give the same extension value?
  3. Why does density of \(E\) in \(K\) imply that a continuous extension to \(K\) is unique?
  4. In the rational example, what value must the extension take at \(1/2\), and why?
  5. Why does compactness of \([0,1]\) not make \(x\mapsto\sin(1/x)\) uniformly continuous on \((0,1]\)?