Much of analysis reduces to a single strategy: prove a result for a restricted class of "nice" objects, then extend it to all objects by approximation. The Chain Rule for [Sobolev functions](/page/Sobolev%20Space) is established by verifying it for smooth functions and passing to the limit. The [Fourier transform](/page/Fourier%20Transform) on $L^2(\mathbb{R}^n)$ is defined by first constructing it on $L^1 \cap L^2$ and extending by continuity. Numerical computation replaces every real number with a rational approximation and controls the error.
The success of this strategy depends on a single topological condition: the nice objects must be **dense** in the larger space. If every element of the space can be approximated arbitrarily well by nice elements, then properties that are stable under limits transfer automatically. If the nice objects are not dense — if there exist elements of the space that no sequence of nice elements can approach — the strategy collapses entirely.
[example: The Failure of Polynomial Approximation on Unbounded Domains]
Consider the space $C([0, \infty))$ of [continuous functions](/page/Continuity%20(Metric%20Spaces)) on the half-line, equipped with the [supremum](/page/Supremum%20and%20Infimum) norm $\|f\|_\infty = \sup_{x \ge 0} |f(x)|$. One might hope that polynomials are dense in this space, as they are in $C([a,b])$ by the Weierstrass Approximation Theorem.
This hope is false. Define the [continuous](/page/Continuity) bounded function $f: [0, \infty) \to \mathbb{R}$ by $f(x) = \sin(x)$. For any polynomial $p$ of degree $n \ge 1$, we have $|p(x)| \to \infty$ as $x \to \infty$, while $|f(x)| \le 1$ for all $x$. Therefore:
\begin{align*}
\|f - p\|_\infty = \sup_{x \ge 0} |f(x) - p(x)| \ge \sup_{x \ge 0} (|p(x)| - 1) = \infty.
\end{align*}
No polynomial can approximate $f$ within any finite tolerance in the supremum norm. The polynomials are not dense in $C([0, \infty))$ — indeed, the closure of the polynomials in this norm consists only of polynomials themselves. The [compactness](/page/Compact%20Space) of the domain in the Weierstrass theorem is not a technical convenience; it is essential.
[/example]
This example illustrates a recurring theme: density is a property of the **pair** (subset, ambient space with its topology), and changing either the subset or the topology can destroy or create density. The same set of polynomials that fails to be dense in $C([0,\infty))$ with the supremum norm becomes dense in $L^2([0,\infty), e^{-x} \, d\mathcal{L}^1)$ — the Laguerre polynomials form an orthonormal basis. Density is not an intrinsic property of the approximating class; it depends critically on how we measure "closeness."
## Definition
[definition: Dense Subset]
Let $(X, \tau)$ be a [topological space](/page/Topology). A subset $D \subset X$ is **dense** in $X$ if for every nonempty [open set](/page/Open%20Set) $G \in \tau$, the intersection $G \cap D \neq \varnothing$.
Equivalently, $D$ is dense in $X$ if its [closure](/page/Closure) equals the entire space:
\begin{align*}
\overline{D} = X.
\end{align*}
[/definition]
The two characterisations reflect different intuitions. The closure condition says that every point of $X$ is either in $D$ or is a limit point of $D$ — no point of $X$ is "isolated from" $D$. The open-set condition says that $D$ penetrates every open region of the space — there is no open set that $D$ avoids entirely.
[remark: Density is Relative]
Density is always stated with respect to a particular ambient space and topology. The set $\mathbb{Q}$ is dense in $\mathbb{R}$ with the standard topology, but $\mathbb{Q}$ is not dense in $\mathbb{R}$ equipped with the discrete topology (where every singleton $\{x\}$ is open). Similarly, $C^\infty_c(U)$ is dense in $L^p(U)$ for $1 \le p < \infty$, but not in $L^\infty(U)$: the closure of $C^\infty_c(U)$ in $L^\infty(U)$ is $C_0(U)$ (functions vanishing at infinity), which is a proper subspace of $L^\infty(U)$ whenever $U$ has positive measure. When we say "$D$ is dense," we always mean dense in a specified space with a specified topology or norm.
[/remark]
In a [metric space](/page/Metric%20Space) $(X, d)$, the definition takes a more concrete form: $D \subset X$ is dense if and only if for every $x \in X$ and every $\varepsilon > 0$, there exists $y \in D$ with $d(x, y) < \varepsilon$. That is, every point of $X$ can be approximated to arbitrary precision by elements of $D$.
[definition: Dense Subset of a Metric Space]
Let $(X, d)$ be a metric space. A subset $D \subset X$ is **dense** in $X$ if for every $x \in X$ and every $\varepsilon > 0$:
\begin{align*}
B(x, \varepsilon) \cap D \neq \varnothing,
\end{align*}
where $B(x, \varepsilon) := \{y \in X : d(x, y) < \varepsilon\}$ is the open ball of radius $\varepsilon$ centred at $x$.
Equivalently, $D$ is dense in $X$ if and only if for every $x \in X$ there exists a [sequence](/page/Sequence) $\{d_k\}_{k=1}^\infty$ in $D$ with $d_k \to x$ as $k \to \infty$.
[/definition]
The sequential characterisation is the workhorse in practice: to show $D$ is dense, we must construct, for each target element $x \in X$, an explicit sequence in $D$ converging to $x$. This construction is the content of every density theorem in analysis.
## Density in the Real Line
The simplest and most fundamental density result concerns the [rational numbers](/page/Rational%20Number) $\mathbb{Q}$ inside $\mathbb{R}$. That every real number can be approximated by rationals is the foundation of decimal expansions, floating-point arithmetic, and the entire edifice of numerical computation. Yet the proof reveals an important structural feature: density says nothing about the "size" of the dense set in the sense of cardinality or measure.
[quotetheorem:740]
The proof relies on the [Archimedean property](/page/Archimedean%20Property): for any $\varepsilon > 0$ there exists $n \in \mathbb{N}$ with $1/n < \varepsilon$. Given an open interval $(a, b)$, choose $n$ so that $1/n < b - a$, and then the integer $m = \lceil na \rceil + 1$ satisfies $a < m/n < b$. The argument is entirely constructive.
What makes this result striking is that $\mathbb{Q}$ is [countable](/page/Countable%20Set) — it is, in a precise sense, a "negligibly small" subset of $\mathbb{R}$. The Lebesgue measure of $\mathbb{Q}$ is zero: $\mathcal{L}^1(\mathbb{Q}) = 0$. A measure-zero set manages to be dense because density is a topological property (about open sets), not a measure-theoretic one (about volume). The irrationals are also dense, also have full measure, and also thread through every open interval — and they are uncountable. The notions of "topologically large" (dense) and "measure-theoretically large" (full measure) are fundamentally independent.
[quotetheorem:741]
The density of irrationals is proved by an analogous argument: if $a < b$ are rational, the number $a + (b - a)/\sqrt{2}$ is irrational and lies in $(a, b)$. The general case reduces to this by first finding rationals inside $(a, b)$. A natural question arises: if both $\mathbb{Q}$ and $\mathbb{R} \setminus \mathbb{Q}$ are dense, can we distinguish them topologically? The answer is no — but they are radically different from a measure-theoretic perspective.
[example: A Nowhere Dense Set with Positive Measure]
The independence of density from measure is sharpened by the following construction. The standard [Cantor set](/page/Cantor%20Set) $C \subset [0,1]$ is closed, has $\mathcal{L}^1(C) = 0$, and is nowhere dense (its closure has empty interior). This shows a set can be "topologically negligible" and "measure-theoretically negligible" simultaneously.
However, a **fat Cantor set** demonstrates that these properties can diverge. Fix $0 < \alpha < 1$. At stage $k$ of the construction, instead of removing the middle third of each interval, remove the middle open interval of length $\alpha / 3^k$ from each of the $2^{k-1}$ intervals at stage $k-1$. The resulting closed set $C_\alpha$ has:
\begin{align*}
\mathcal{L}^1(C_\alpha) &= 1 - \sum_{k=1}^\infty 2^{k-1} \cdot \frac{\alpha}{3^k} = 1 - \frac{\alpha}{3} \sum_{k=0}^\infty \left(\frac{2}{3}\right)^k = 1 - \frac{\alpha}{3} \cdot 3 = 1 - \alpha > 0.
\end{align*}
Yet $C_\alpha$ is nowhere dense: at each stage we remove an open interval from the middle of every remaining piece, so no interval is contained in $C_\alpha$, and since $C_\alpha$ is closed, $\overline{C_\alpha} = C_\alpha$ has empty interior. Thus $C_\alpha$ is a nowhere dense closed set with positive Lebesgue measure $1 - \alpha$, which can be made arbitrarily close to $1$.
The complement $[0,1] \setminus C_\alpha$ is open and dense in $[0,1]$ (its closure is all of $[0,1]$ because $C_\alpha$ has empty interior), yet it has measure only $\alpha$, which can be made arbitrarily small. A dense open set can have arbitrarily small measure — density and measure are genuinely orthogonal notions.
[/example]
## Approximation in Function Spaces
The most consequential applications of density occur in function spaces, where the dense subset consists of "nice" functions (polynomials, smooth functions, simple functions) and the ambient space consists of functions satisfying weaker regularity conditions ($L^p$ functions, [Sobolev functions](/page/Sobolev%20Space), continuous functions). Each density theorem in this section answers a specific question: which functions can be approximated, and in what sense?
### Polynomials in $C([a,b])$: The Weierstrass Theorem
A natural first question is whether the simplest class of "computable" functions — polynomials — suffices to approximate arbitrary continuous functions on a compact interval. The affirmative answer was established by Weierstrass in 1885 and remains one of the most important results in approximation theory.
[quotetheorem:480]
The theorem admits several constructive approaches. Bernstein's proof provides an explicit approximating polynomial: for $f \in C([0,1])$, the $n$-th Bernstein polynomial is:
\begin{align*}
B_n(f)(x) := \sum_{k=0}^n f\left(\frac{k}{n}\right) \binom{n}{k} x^k (1-x)^{n-k}.
\end{align*}
Each $B_n(f)$ is a polynomial of degree at most $n$, and $B_n(f) \to f$ uniformly on $[0,1]$. The construction has a probabilistic interpretation: $B_n(f)(x)$ is the expected value of $f(S_n/n)$ where $S_n$ is a binomial random variable with parameters $n$ and $x$. As $n \to \infty$, the law of large numbers concentrates $S_n/n$ around $x$, and continuity of $f$ turns this concentration into convergence.
The Weierstrass theorem was generalised dramatically by Stone, who replaced $[a,b]$ with an arbitrary compact Hausdorff space and polynomials with any subalgebra that separates points.
[quotetheorem:886]
Case (ii) occurs precisely when every function in $A$ vanishes at some common point $x_0$. If the subalgebra contains a nonzero constant (or more generally, a function that is nonzero everywhere), only case (i) is possible. The Weierstrass theorem follows as the special case $K = [a,b]$, $A = $ polynomials: polynomials separate points (the polynomial $p(x) = x$ already does) and contain the constants.
The Stone-Weierstrass theorem is the primary tool for proving density in spaces of continuous functions. Its power lies in the algebraic criterion — we need only verify that the approximating class is a subalgebra separating points, without constructing explicit approximations.
[example: Trigonometric Polynomials Are Dense in $C([-\pi, \pi])$]
Consider the space $C([-\pi, \pi])$ of continuous functions on $[-\pi, \pi]$ that satisfy $f(-\pi) = f(\pi)$ (so they can be viewed as continuous functions on the circle $\mathbb{T} = \mathbb{R} / 2\pi\mathbb{Z}$). Let $A$ be the set of trigonometric polynomials:
\begin{align*}
A = \left\{ \sum_{k=-N}^N c_k e^{ikx} : N \in \mathbb{N}_0, \, c_k \in \mathbb{C} \right\}.
\end{align*}
We verify the Stone-Weierstrass hypotheses on the compact space $\mathbb{T}$:
**Subalgebra:** $A$ is closed under addition, scalar multiplication, and pointwise multiplication (the product of two trigonometric polynomials is again a trigonometric polynomial). It is also closed under complex conjugation since $\overline{e^{ikx}} = e^{-ikx}$.
**Separates points:** If $x \neq y$ in $\mathbb{T}$, then $e^{ix} \neq e^{iy}$ (since $x - y \not\in 2\pi\mathbb{Z}$), so the function $f(t) = e^{it} \in A$ separates $x$ and $y$.
**Contains constants:** The function $f(t) = 1$ is a trigonometric polynomial (take $N = 0$, $c_0 = 1$).
By the Stone-Weierstrass theorem, $\overline{A} = C(\mathbb{T}; \mathbb{C})$. Restricting to real parts, the real trigonometric polynomials $\{a_0 + \sum_{k=1}^N (a_k \cos kx + b_k \sin kx)\}$ are dense in $C(\mathbb{T}; \mathbb{R})$. This density is the analytical foundation for [Fourier series](/page/Fourier%20Series): the convergence of the Fourier series in $L^2$ follows from the Hilbert space theory, but its connection to uniform approximation requires the density of trigonometric polynomials in the supremum norm.
[/example]
### Simple Functions and Smooth Functions in $L^p$
In measure theory and integration, the fundamental building blocks are simple functions — finite linear combinations of indicator functions of measurable sets. A natural question arises: can every integrable function be approximated by these discrete, step-like objects? The affirmative answer is the engine behind the construction of the Lebesgue integral itself.
[quotetheorem:893]
The density of simple functions is established by the standard truncation-and-discretization procedure. For a nonnegative $f \in L^p(E)$, define:
\begin{align*}
f_k(x) := \begin{cases}
k & \text{if } f(x) \ge k, \\
\frac{j-1}{2^k} & \text{if } \frac{j-1}{2^k} \le f(x) < \frac{j}{2^k}, \quad j = 1, \ldots, k \cdot 2^k.
\end{cases}
\end{align*}
Each $f_k$ is a simple function, $0 \le f_k \le f_{k+1} \le f$ pointwise, $f_k \to f$ pointwise, and $|f - f_k|^p \le |f|^p \in L^1$. The [Dominated Convergence Theorem](/theorems/4) gives $\|f - f_k\|_{L^p} \to 0$.
The density of $C_c^\infty(U)$ in $L^p(U)$ requires more work. The argument proceeds in stages: first approximate $f$ by simple functions, then approximate each indicator function $\mathbb{1}_A$ by continuous functions (using inner regularity of Lebesgue measure), and finally smooth these continuous approximations by [mollification](/page/Sobolev%20Space). The restriction $p < \infty$ is essential: $C_c^\infty(U)$ is not dense in $L^\infty(U)$.
[example: $L^\infty$ Failure of Smooth Approximation]
Let $U = (0, 1) \subset \mathbb{R}$ and consider the function $f = \mathbb{1}_{(0, 1/2)} \in L^\infty(U)$. Suppose $\varphi \in C_c^\infty(U)$ satisfies $\|f - \varphi\|_{L^\infty(U)} < 1/4$. Then $\varphi(x) > 3/4$ for $x \in (0, 1/2)$ and $\varphi(x) < 1/4$ for $x \in (1/2, 1)$. By the intermediate value theorem, $\varphi$ must pass through $1/2$ at some point near $x = 1/2$. But the jump from $3/4$ to $1/4$ happens across the single point $x = 1/2$, and continuity of $\varphi$ forces:
\begin{align*}
|\varphi(1/2 - \delta) - \varphi(1/2 + \delta)| \to |\varphi(1/2^-) - \varphi(1/2^+)| = 0
\end{align*}
as $\delta \to 0$. However, we need $\varphi(1/2 - \delta) > 3/4$ and $\varphi(1/2 + \delta) < 1/4$, which gives a difference of at least $1/2$ for all small $\delta > 0$. This contradicts the continuity of $\varphi$. Hence $\|f - \varphi\|_{L^\infty} \ge 1/4$ for every $\varphi \in C_c^\infty(U)$, and the indicator function $\mathbb{1}_{(0,1/2)}$ lies outside the $L^\infty$-closure of $C_c^\infty(U)$.
The underlying obstruction is that $L^\infty$ convergence preserves continuity: if $\varphi_k \to g$ uniformly and each $\varphi_k$ is continuous, then $g$ is continuous. Thus the closure of $C_c^\infty(U)$ in $L^\infty(U)$ is contained in the space of continuous functions vanishing at the boundary — which is far smaller than $L^\infty(U)$.
[/example]
### Smooth Functions in Sobolev Spaces: The Meyers-Serrin Theorem
In the theory of [Sobolev spaces](/page/Sobolev%20Space), [weak derivatives](/page/Weak%20Derivative) are defined by an integration-by-parts identity, not by pointwise limits of difference quotients. This creates a fundamental obstacle: classical calculus rules (the Chain Rule, the Product Rule, changes of variables) apply to smooth functions, not directly to functions with merely weak derivatives. To transfer these rules to Sobolev functions, we need a density result ensuring that every [Sobolev function](/page/Sobolev%20Space) can be approximated — in the full Sobolev norm, controlling both the function and its derivatives — by smooth functions.
[quotetheorem:58]
The notation "$H = W$" reflects the historical context. The space $H^{k,p}(\Omega)$ was originally defined as the closure of smooth functions in the $W^{k,p}$ norm, while $W^{k,p}(\Omega)$ was defined via weak derivatives. The Meyers-Serrin theorem proves these two definitions yield the same space — a fact that is not at all evident from the definitions.
A critical subtlety: the theorem produces functions that are smooth **inside** $\Omega$, not up to the boundary. The approximating function $v$ may behave wildly near $\partial \Omega$. Approximation by functions smooth up to the boundary — that is, density of $C^\infty(\overline{\Omega})$ in $W^{k,p}(\Omega)$ — requires additional geometric hypotheses on $\partial \Omega$ (such as the segment condition or Lipschitz regularity). This distinction is essential in boundary value problems, where the trace operator requires control up to $\partial \Omega$.
[explanation: Why Interior Smoothness Suffices for Calculus Rules]
At first glance, the restriction to interior smoothness may seem insufficient. If $v$ is smooth only inside $\Omega$ and potentially irregular near $\partial \Omega$, how can we apply classical calculus to $v$?
The answer lies in the structure of the density argument. When proving a calculus rule for $u \in W^{k,p}(\Omega)$, we:
1. Choose $v_m \in C^\infty(\Omega) \cap W^{k,p}(\Omega)$ with $v_m \to u$ in $W^{k,p}(\Omega)$.
2. Verify the rule for $v_m$. Since $v_m$ is $C^\infty$ on $\Omega$, classical calculus applies on every compact subset $K \subset \Omega$. The rule holds on each $K$, and since the $W^{k,p}$ norm integrates over all of $\Omega$, the rule holds as an identity between $L^p$ functions on $\Omega$.
3. Pass to the limit using the $W^{k,p}$ convergence.
The boundary behavior of $v_m$ is irrelevant because we never need pointwise control at $\partial \Omega$ — we only need the $L^p$-based Sobolev norm, which is insensitive to behavior on the measure-zero set $\partial \Omega$.
[/explanation]
## Nowhere Dense Sets and the Baire Category Theorem
Density describes sets that are "topologically large" — they reach into every open set. The opposite extreme consists of sets that are "topologically negligible," failing to be dense in even the smallest open region. Understanding this dichotomy leads to the [Baire category theorem](/page/Baire%20Category%20Theorem), one of the most powerful tools in functional analysis.
[definition: Nowhere Dense Set]
Let $(X, \tau)$ be a [topological space](/page/Topology). A subset $A \subset X$ is **nowhere dense** in $X$ if its closure $\overline{A}$ has empty [interior](/page/Interior):
\begin{align*}
\operatorname{int}(\overline{A}) = \varnothing.
\end{align*}
Equivalently, $A$ is nowhere dense if for every nonempty open set $G \subset X$, there exists a nonempty open set $H \subset G$ with $H \cap A = \varnothing$.
[/definition]
The second characterisation captures the intuition: no matter how small an open region you examine, there is always a sub-region that $A$ completely misses. A dense set penetrates every open set; a nowhere dense set can be "avoided" in every open set.
[example: Nowhere Dense Sets in $\mathbb{R}$]
The integers $\mathbb{Z}$ are nowhere dense in $\mathbb{R}$: every open interval $(a, b)$ of length greater than $1$ contains an integer, but the closure $\overline{\mathbb{Z}} = \mathbb{Z}$ has empty interior (no open interval is contained in $\mathbb{Z}$). More precisely, for any open interval $(a, b)$, the sub-interval $(a, \lfloor a \rfloor + 1)$ (if $a \notin \mathbb{Z}$) avoids $\mathbb{Z}$ entirely.
The [Cantor set](/page/Cantor%20Set) $C$ is a more subtle example: it is uncountable, closed, and nowhere dense. Since $C$ is closed, $\overline{C} = C$. At each stage of the construction, the middle third of every remaining interval is removed, so no interval of length $3^{-k}$ is contained in $C$ for any $k$, and thus $\operatorname{int}(C) = \varnothing$.
[/example]
A single nowhere dense set is topologically small, but what about countable unions? A countable union of nowhere dense sets is called a **meagre set** (or a set of **first category**). The Baire Category Theorem asserts that in complete metric spaces, countable unions of nowhere dense sets cannot exhaust the whole space — the complement of a meagre set is always dense.
[quotetheorem:630]
The two forms are logically equivalent. If $\{G_k\}$ are dense open sets, their complements $F_k = X \setminus G_k$ are closed with empty interior (i.e., nowhere dense). If $\bigcap G_k$ were not dense, its complement $\bigcup F_k$ would contain a nonempty open set, contradicting form (2). Conversely, form (2) follows from (1) by taking complements.
The Baire Category Theorem has profound consequences for density. It implies, for instance, that a complete metric space cannot be written as a countable union of "thin" closed sets. This has striking applications in functional analysis.
[example: The Continuous Nowhere Differentiable Functions are Dense]
Consider the Banach space $C([0,1])$ with the supremum norm. By the Baire Category Theorem, the set of continuous functions that are differentiable at least at one point is meagre in $C([0,1])$. More precisely, for each $x_0 \in [0,1]$ and each $M > 0$, the set:
\begin{align*}
E_{x_0, M} := \left\{ f \in C([0,1]) : \limsup_{h \to 0} \left| \frac{f(x_0 + h) - f(x_0)}{h} \right| \le M \right\}
\end{align*}
is closed (it is defined by a $\limsup$ condition) and has empty interior in $C([0,1])$ (given any [continuous function](/page/Continuity%20(Metric%20Spaces)) $g$ and $\varepsilon > 0$, one can perturb $g$ by a small sawtooth to make the difference quotients at $x_0$ exceed $M$). The set of functions differentiable at $x_0$ is $\bigcup_{M=1}^\infty E_{x_0, M}$, a countable union of nowhere dense sets. Taking a countable union over $x_0 \in \mathbb{Q} \cap [0,1]$ shows that functions differentiable at any rational point form a meagre set. A more refined argument covers all points.
The complement — functions that are nowhere differentiable — is a dense $G_\delta$ subset of $C([0,1])$. In the sense of Baire category, "most" continuous functions are nowhere differentiable. This is a density result of a different flavour: the "generic" continuous function is far more pathological than the smooth functions that are dense in the same space.
[/example]
## Continuous Extensions from Dense Subsets
One of the most useful consequences of density is that a [continuous](/page/Continuity) map defined on a dense subset is, under mild conditions, uniquely determined by — and can be extended to — the entire space. This principle underlies the definition of the Fourier transform on $L^2$ (defined first on $L^1 \cap L^2$, which is dense), the extension of [bounded linear operators](/page/Linear%20Operators%20on%20Banach%20Spaces) between Banach spaces, and the construction of completions.
The fundamental question is: if $D$ is dense in $X$, $Y$ is a [complete metric space](/page/Complete%20Metric%20Space), and $f: D \to Y$ is uniformly continuous, can $f$ be extended to a continuous map $\overline{f}: X \to Y$?
[quotetheorem:964]
The proof constructs $\overline{f}(x)$ as follows: since $D$ is dense, choose a sequence $\{d_k\}_{k=1}^\infty$ in $D$ with $d_k \to x$. Since $f$ is uniformly continuous and $\{d_k\}$ is Cauchy in $X$, the sequence $\{f(d_k)\}$ is Cauchy in $Y$. Completeness of $Y$ gives a limit, and uniform continuity ensures this limit is independent of the choice of approximating sequence.
The hypotheses cannot be weakened. Mere continuity of $f$ is insufficient: the function $f: \mathbb{Q} \to \mathbb{R}$ defined by $f(q) = \mathbb{1}_{\{q > \sqrt{2}\}}$ (with the convention that $f$ takes the value $0$ for $q < \sqrt{2}$ and $1$ for $q > \sqrt{2}$) is locally constant on $\mathbb{Q}$ (hence continuous), but has no continuous extension to $\mathbb{R}$ because the "jump" occurs at the irrational point $\sqrt{2}$. Uniform continuity prevents such jumps. Completeness of $Y$ is also essential: the identity map $f: \mathbb{Q} \to \mathbb{Q}$ is an isometry (hence uniformly continuous), but there is no continuous map $\overline{f}: \mathbb{R} \to \mathbb{Q}$ extending it — the rationals have "gaps" that prevent [Cauchy sequences](/page/Cauchy%20Sequence) from converging.
[explanation: Uniqueness of Continuous Extensions]
The **uniqueness** statement in the extension theorem is often more immediately useful than the existence. If $f, g: X \to Y$ are two [continuous maps](/page/Continuity%20(Metric%20Spaces)) that agree on a dense subset $D \subset X$, and $Y$ is Hausdorff, then $f = g$ on all of $X$.
The proof is a direct application of the definition of density. The set $\{x \in X : f(x) = g(x)\}$ is closed (as the preimage of the diagonal under the continuous map $x \mapsto (f(x), g(x))$ into $Y \times Y$, and the diagonal is closed since $Y$ is Hausdorff). This closed set contains $D$, hence contains $\overline{D} = X$.
This uniqueness principle is pervasive:
- The [Fourier transform](/page/Fourier%20Transform) on $L^2(\mathbb{R}^n)$ is the **unique** bounded linear extension of the Fourier transform from $L^1(\mathbb{R}^n) \cap L^2(\mathbb{R}^n)$ (which is dense in $L^2$).
- If two Borel probability measures on $\mathbb{R}$ agree on all continuous bounded test functions, they are equal — because continuous bounded functions determine the weak topology, and the continuous functions $f(x) = e^{itx}$ (which determine the characteristic function) separate measures.
- A [bounded linear operator](/page/Linear%20Operators%20on%20Banach%20Spaces) $T: X \to Y$ between [normed vector spaces](/page/Normed%20Vector%20Space) is completely determined by its action on any dense subspace of $X$.
[/explanation]
The most important special case in functional analysis is the extension of bounded linear operators.
[quotetheorem:965]
The boundedness condition $\|Tx\| \le C\|x\|$ implies uniform continuity (since $\|Tx - Ty\| \le C\|x - y\|$), so this is a special case of the continuous extension theorem. The additional content is that the extension is linear and preserves the operator norm exactly.
## Separability
Density becomes especially powerful when the dense subset is **countable**. A topological space containing a countable dense subset is called [separable](/page/Separable%20Space), and [separability](/page/Separable) is one of the most useful structural properties a space can possess. It ensures that the space is, in a precise sense, "controlled" by countably many elements — which is essential for constructing sequences, applying diagonalization arguments, and establishing the existence of countable bases.
[definition: Separable Space]
A topological space $(X, \tau)$ is **separable** if it contains a countable dense subset. That is, there exists a countable set $D = \{d_1, d_2, d_3, \ldots\} \subset X$ such that $\overline{D} = X$.
[/definition]
In general [topological spaces](/page/Topology), separability does not imply second countability or the Lindelöf property. However, in the [metrizable](/page/Metrizable%20Space) setting, all three conditions are equivalent — a fact that makes separability far more powerful than its definition suggests.
[quotetheorem:545]
The equivalence of separability and second countability in metrizable spaces is a deep structural result. Second countability is often easier to verify and has stronger consequences (for instance, it implies that every open cover has a countable subcover, which is essential for measure-theoretic constructions).
[example: Separability and Non-Separability of $L^p$ Spaces]
The Lebesgue spaces exhibit a sharp dichotomy in separability.
**$L^p(U)$ is separable for $1 \le p < \infty$.** A countable dense subset is given by finite rational linear combinations of indicator functions of rational-endpoint boxes. Concretely, for $U \subset \mathbb{R}^n$ open, consider the set:
\begin{align*}
D := \left\{ \sum_{j=1}^N q_j \, \mathbb{1}_{R_j} : N \in \mathbb{N}, \, q_j \in \mathbb{Q}, \, R_j = \prod_{i=1}^n (a_i, b_i) \text{ with } a_i, b_i \in \mathbb{Q}, \, R_j \subset U \right\}.
\end{align*}
This set is countable (it is a countable union of finite products of countable sets). To see that $D$ is dense in $L^p(U)$, we use the density chain: every $f \in L^p(U)$ can be approximated by simple functions (truncation and discretization), each simple function can be approximated by linear combinations of indicators of bounded measurable sets, each such indicator can be approximated by indicators of open sets (regularity of Lebesgue measure), and each open set can be written as a countable union of rational boxes. Rational coefficients handle the remaining approximation.
**$L^\infty(U)$ is not separable whenever $\mathcal{L}^n(U) > 0$.** For each $x \in U$, there exists $r_x > 0$ with $B(x, r_x) \subset U$. The family $\{\mathbb{1}_{B(x, r_x)}\}_{x \in U}$ is uncountable. For distinct $x, y \in U$ with $|x - y|$ sufficiently large (exceeding $r_x + r_y$), the balls $B(x, r_x)$ and $B(y, r_y)$ are disjoint, and:
\begin{align*}
\|\mathbb{1}_{B(x, r_x)} - \mathbb{1}_{B(y, r_y)}\|_{L^\infty} = 1.
\end{align*}
More carefully: for $t \in (0,1)$, consider the family $\{f_t\}_{t \in (0,1)}$ where $f_t = \mathbb{1}_{(0,t)}$ in $L^\infty((0,1))$. For $s \neq t$, $\|f_s - f_t\|_{L^\infty} = 1$. Any dense subset must contain a distinct element within distance $1/2$ of each $f_t$, so the dense subset must be uncountable.
[/example]
The failure of separability for $L^\infty$ is not merely a technical inconvenience — it reflects a fundamental structural deficiency. In a non-separable space, sequences are insufficient to characterize the topology (there exist points in the closure of a set that are not limits of sequences from the set). Many of the standard tools of functional analysis — sequential weak compactness, [metrizability](/page/Metrizable%20Space) of the weak topology on bounded sets, existence of Schauder bases — require or benefit from separability.
## The Density Argument
The results of the preceding sections are not ends in themselves — they are ingredients in a pervasive proof technique that appears throughout analysis. The **density argument** (also called "approximation-then-passage-to-the-limit") is a three-step method for proving that a property, initially established for a restricted class, holds for all elements of a function space.
The abstract structure is as follows. Let $X$ be a [normed space](/page/Normed%20Vector%20Space), let $D \subset X$ be a dense subspace, and let $P$ be a property of elements of $X$ (typically an inequality, an identity, or membership in a set). The density argument establishes $P$ for all $x \in X$ by:
**Step 1 (Prove for the dense class).** Verify that $P(d)$ holds for every $d \in D$, using tools available for the nice class (classical calculus, algebraic manipulations, explicit computation).
**Step 2 (Approximate).** For a general $x \in X$, choose a sequence $\{d_k\}_{k=1}^\infty \subset D$ with $d_k \to x$ in $X$.
**Step 3 (Pass to the limit).** Show that $P$ is preserved under limits: if $P(d_k)$ holds for each $k$ and $d_k \to x$, then $P(x)$ holds.
The difficulty almost always lies in Step 3. The property $P$ must be **closed** in the appropriate sense — which typically means that the quantities involved are continuous with respect to the norm on $X$.
[example: Proving the Integration-by-Parts Identity in $W^{1,p}$]
We illustrate the density argument by establishing the integration-by-parts identity for Sobolev functions, which is the very definition that motivates the theory.
**Claim.** Let $U \subset \mathbb{R}^n$ be open, let $u \in W^{1,p}(U)$ and $\varphi \in C_c^\infty(U)$. Then:
\begin{align*}
\int_U u \, \partial_{x_i} \varphi \, d\mathcal{L}^n = -\int_U (\partial_{x_i} u) \, \varphi \, d\mathcal{L}^n.
\end{align*}
**Step 1.** For $v \in C^\infty(U) \cap W^{1,p}(U)$, this identity is the classical integration-by-parts formula. Since $\varphi$ has compact support in $U$, the boundary terms vanish, and the identity holds by the divergence theorem applied to the compactly supported vector field $v \varphi \, e_i$.
**Step 2.** By the [Meyers-Serrin theorem](/theorems/58), choose $v_k \in C^\infty(U) \cap W^{1,p}(U)$ with $v_k \to u$ in $W^{1,p}(U)$. In particular, $v_k \to u$ in $L^p(U)$ and $\partial_{x_i} v_k \to \partial_{x_i} u$ in $L^p(U)$.
**Step 3.** We pass to the limit on each side of the identity $\int_U v_k \, \partial_{x_i} \varphi \, d\mathcal{L}^n = -\int_U (\partial_{x_i} v_k) \, \varphi \, d\mathcal{L}^n$.
For the left side: since $\partial_{x_i}\varphi \in C_c^\infty(U) \subset L^{p'}(U)$ (where $p' = p/(p-1)$ is the conjugate exponent) and $v_k \to u$ in $L^p(U)$, Holder's inequality gives:
\begin{align*}
\left| \int_U (v_k - u) \partial_{x_i} \varphi \, d\mathcal{L}^n \right| \le \|v_k - u\|_{L^p(U)} \|\partial_{x_i}\varphi\|_{L^{p'}(U)} \to 0.
\end{align*}
For the right side: since $\varphi \in L^{p'}(U)$ and $\partial_{x_i} v_k \to \partial_{x_i} u$ in $L^p(U)$, the same estimate gives:
\begin{align*}
\left| \int_U (\partial_{x_i} v_k - \partial_{x_i} u) \varphi \, d\mathcal{L}^n \right| \le \|\partial_{x_i} v_k - \partial_{x_i} u\|_{L^p(U)} \|\varphi\|_{L^{p'}(U)} \to 0.
\end{align*}
Taking $k \to \infty$, both sides converge, and the identity passes to the limit.
[/example]
The passage to the limit in this example used only Holder's inequality and the definition of convergence in $L^p$. In more sophisticated applications, Step 3 may require weak lower semicontinuity, the Dominated Convergence Theorem, or compactness arguments (extracting a subsequence that converges in a weaker sense).
[example: Extending an Inequality by Density]
A common application of the density argument is extending an inequality from smooth functions to Sobolev functions. Consider the [Gagliardo-Nirenberg-Sobolev inequality](/theorems/61): for $1 \le p < n$ and $u \in W^{1,p}(\mathbb{R}^n)$:
\begin{align*}
\|u\|_{L^{p^*}(\mathbb{R}^n)} \le C(n, p) \|\nabla u\|_{L^p(\mathbb{R}^n)}, \quad p^* = \frac{np}{n-p}.
\end{align*}
**Step 1.** The inequality is first proved for $u \in C_c^\infty(\mathbb{R}^n)$ by a direct computation (integrating the fundamental theorem of calculus in each coordinate direction).
**Step 2.** For general $u \in W^{1,p}(\mathbb{R}^n)$, choose $u_k \in C_c^\infty(\mathbb{R}^n)$ with $u_k \to u$ in $W^{1,p}(\mathbb{R}^n)$. (Such a sequence exists because $C_c^\infty(\mathbb{R}^n)$ is dense in $W^{1,p}(\mathbb{R}^n)$ — this follows from the Meyers-Serrin theorem combined with a cut-off argument.)
**Step 3.** From Step 1, $\|u_k\|_{L^{p^*}} \le C \|\nabla u_k\|_{L^p}$. Since $u_k \to u$ in $W^{1,p}$, we have $\nabla u_k \to \nabla u$ in $L^p$, so $\|\nabla u_k\|_{L^p} \to \|\nabla u\|_{L^p}$. For the left side, $u_k \to u$ in $L^p$, and the inequality $\|u_k\|_{L^{p^*}} \le C\|\nabla u_k\|_{L^p} \le C(\|\nabla u\|_{L^p} + 1)$ shows $\{u_k\}$ is bounded in $L^{p^*}$. Extracting a subsequence converging weakly in $L^{p^*}$ and using lower semicontinuity of the norm under weak convergence:
\begin{align*}
\|u\|_{L^{p^*}} \le \liminf_{k \to \infty} \|u_k\|_{L^{p^*}} \le C \lim_{k \to \infty} \|\nabla u_k\|_{L^p} = C\|\nabla u\|_{L^p}.
\end{align*}
The inequality extends to all of $W^{1,p}(\mathbb{R}^n)$.
The critical observation in Step 3 is the use of **weak lower semicontinuity of the norm**: $\|x\| \le \liminf \|x_k\|$ whenever $x_k \rightharpoonup x$ weakly. This is the standard tool for extending inequalities by density when the left side involves a norm — direct strong convergence of $\|u_k\|_{L^{p^*}} \to \|u\|_{L^{p^*}}$ is not guaranteed because $u_k \to u$ in $L^p$ does not imply $u_k \to u$ in $L^{p^*}$.
[/example]
### When the Density Argument Fails
The density argument requires that the property $P$ be stable under the type of convergence available. When the convergence is too weak to preserve $P$, the argument breaks down. Understanding these failures is as important as mastering the technique itself.
The most common failure mode occurs when $P$ involves pointwise properties. For instance, nonnegativity ($u \ge 0$ a.e.) is preserved under $L^p$ convergence (if $u_k \ge 0$ and $u_k \to u$ in $L^p$, then $u \ge 0$ a.e. after passing to a pointwise a.e. convergent subsequence). But strict positivity ($u > 0$ a.e.) is not: the functions $u_k(x) = 1/k$ converge to $u = 0$ in every $L^p$ norm. Similarly, boundedness ($\|u\|_{L^\infty} \le M$) is not preserved under $L^p$ convergence for $p < \infty$.
A subtler failure occurs with analyticity. Real-analytic functions are dense in $C([a,b])$ (the Weierstrass theorem provides polynomial, hence analytic, approximations), and analytic functions are also dense in $L^2([a,b])$. But the property of being analytic is not preserved under $L^2$ limits — the $L^2$ limit of analytic functions can be any $L^2$ function. In this case, $P =$ "analyticity" is not closed in the $L^2$ topology. The density of analytic functions in $L^2$ is a statement about the topology of $L^2$, not about the structure of analytic functions.
## References
1. Munkres, J. R., *[Topology](/page/Topology)* (2000).
2. Rudin, W., *Principles of Mathematical Analysis* (1976).
3. Rudin, W., *Real and Complex Analysis* (1987).
4. Brezis, H., *Functional Analysis, [Sobolev Spaces](/page/Sobolev%20Space) and Partial Differential Equations* (2011).
5. Evans, L. C., *Partial Differential Equations* (2010).
6. Folland, G. B., *Real Analysis: Modern Techniques and Their Applications* (1999).