18 The Stone–Weierstrass Theorem
Every continuous function on a closed interval can be uniformly approximated by polynomials. This is Weierstrass’s theorem, proved in 1885. Stone’s generalisation identifies the exact algebraic condition on a subalgebra of \(C(K)\) that makes uniform density possible.
18.1 The Weierstrass approximation theorem
Theorem 18.1 (Weierstrass approximation theorem) For every \(f \in C([a,b])\) and every \(\varepsilon > 0\), there exists a polynomial \(p\) such that \(\|f - p\|_\infty < \varepsilon\).
Equivalently, the polynomials are dense in \(C([a,b])\) under the sup-norm.
There are several proofs. The most transparent uses Bernstein polynomials, which have an explicit probabilistic interpretation and give quantitative approximation rates.
Definition 18.1 (Bernstein polynomials) For \(f \in C([0,1])\) and \(n \geq 1\), the \(n\)-th Bernstein polynomial is \[ B_n(f)(x) = \sum_{k=0}^n f\!\left(\frac{k}{n}\right) \binom{n}{k} x^k (1-x)^{n-k}. \]
The sum evaluates \(f\) at equally spaced points \(k/n\), weights each value by the binomial probability of \(k\) successes in \(n\) trials with success probability \(x\), and sums. The approximation theorem is therefore the statement that this probabilistic averaging converges uniformly.
Proof (Proof of the Weierstrass theorem via Bernstein polynomials). It suffices to prove the result on \([0,1]\); a linear change of variables handles the general case.
Step 1: Algebraic identities. From the binomial theorem: \[ \sum_{k=0}^n \binom{n}{k} x^k (1-x)^{n-k} = 1, \quad \sum_{k=0}^n \frac{k}{n} \binom{n}{k} x^k (1-x)^{n-k} = x. \] A further computation gives: \[ \sum_{k=0}^n \left(\frac{k}{n} - x\right)^2 \binom{n}{k} x^k (1-x)^{n-k} = \frac{x(1-x)}{n} \leq \frac{1}{4n}. \]
Step 2: Uniform approximation. Since \(f\) is continuous on the compact set \([0,1]\), it is uniformly continuous. Given \(\varepsilon > 0\), choose \(\delta > 0\) such that \(|f(s) - f(t)| < \varepsilon/2\) whenever \(|s - t| < \delta\). Let \(M = \|f\|_\infty\).
Using the first identity, \(f(x) = \sum_{k=0}^n f(x) \binom{n}{k} x^k(1-x)^{n-k}\), so: \[ |B_n(f)(x) - f(x)| \leq \sum_{k=0}^n \left|f\!\left(\frac{k}{n}\right) - f(x)\right| \binom{n}{k} x^k (1-x)^{n-k}. \] Split the sum into two parts according to whether \(|k/n - x| < \delta\) or \(|k/n - x| \geq \delta\).
For the first part: each term contributes at most \((\varepsilon/2)\binom{n}{k} x^k(1-x)^{n-k}\), and the total is at most \(\varepsilon/2\).
For the second part: \(|f(k/n) - f(x)| \leq 2M\), and we bound the weight by \[ \binom{n}{k} x^k (1-x)^{n-k} \leq \frac{1}{\delta^2}\left(\frac{k}{n}-x\right)^2 \binom{n}{k} x^k(1-x)^{n-k}, \] since \(|k/n - x| \geq \delta\) implies \(1 \leq (k/n-x)^2/\delta^2\). Summing over all \(k\) and using the variance identity: \[ \text{second part} \leq \frac{2M}{\delta^2} \cdot \frac{1}{4n} = \frac{M}{2n\delta^2}. \] For \(n > M/(\varepsilon \delta^2)\), the second part is less than \(\varepsilon/2\). Therefore \(\|B_n(f) - f\|_\infty < \varepsilon\) for all sufficiently large \(n\). \(\square\)
The proof reveals why Bernstein polynomials work: the weights \(\binom{n}{k} x^k(1-x)^{n-k}\) concentrate near \(k/n = x\) as \(n \to \infty\) (the law of large numbers), so \(B_n(f)(x)\) sees only the values of \(f\) near \(x\).
Exercise. Show that for \(f(x) = x^2\), \(B_n(f)(x) = x^2 + x(1-x)/n\). Deduce that \(B_n(f) \to f\) uniformly.
Using the identity \(\sum (k/n)^2 \binom{n}{k} x^k (1-x)^{n-k} = x^2 + x(1-x)/n\) (which follows from computing \(\mathbb{E}[(X/n)^2]\) for \(X \sim \text{Bin}(n,x)\) using \(\mathbb{E}[X^2] = \text{Var}(X) + (\mathbb{E}[X])^2 = nx(1-x) + n^2 x^2\)): \[ B_n(f)(x) = \sum_{k=0}^n \left(\frac{k}{n}\right)^2 \binom{n}{k} x^k(1-x)^{n-k} = x^2 + \frac{x(1-x)}{n}. \] Since \(x(1-x) \leq 1/4\) on \([0,1]\), \(\|B_n(f) - f\|_\infty = \|x(1-x)/n\|_\infty \leq 1/(4n) \to 0\). \(\square\)
18.2 The Stone–Weierstrass theorem
Weierstrass’s theorem is about polynomials on intervals. Stone identified the abstract mechanism: polynomials are a subalgebra of \(C([a,b])\) that separates points and contains the constants. Any subalgebra with these two properties is dense.
Definition 18.2 (Subalgebras and separation) A subset \(\mathcal{A} \subset C(K)\) is a subalgebra if it is closed under pointwise addition, scalar multiplication, and multiplication: \(f, g \in \mathcal{A}\) and \(\lambda \in \mathbb{R}\) imply \(f + g\), \(\lambda f\), and \(fg\) all lie in \(\mathcal{A}\).
\(\mathcal{A}\) separates points if for every \(x \neq y\) in \(K\), there exists \(f \in \mathcal{A}\) with \(f(x) \neq f(y)\).
Theorem 18.2 (Stone–Weierstrass theorem) Let \(K\) be a compact Hausdorff space and \(\mathcal{A} \subset C(K)\) a subalgebra that separates points and contains the constant functions. Then \(\mathcal{A}\) is dense in \(C(K)\) under the sup-norm.
The proof proceeds in stages. The key analytic input is that \(|f|\) can be uniformly approximated by polynomials in \(f\) — which follows from Weierstrass’s theorem applied to \(|t|\) on \([-M, M]\).
Proof. Let \(\overline{\mathcal{A}}\) denote the closure of \(\mathcal{A}\) in \(C(K)\).
Step 1: \(\overline{\mathcal{A}}\) is a closed subalgebra. Closure is preserved under the pointwise operations (which are continuous in \(\|\cdot\|_\infty\)), and \(\overline{\mathcal{A}}\) contains the constants.
Step 2: \(\overline{\mathcal{A}}\) is closed under \(|\cdot|\). Let \(f \in \overline{\mathcal{A}}\) and set \(M = \|f\|_\infty\). By the Weierstrass theorem, there exist polynomials \(p_n\) with \(\|p_n - |\cdot|\|_{C([-M,M])} < 1/n\). Then \(p_n(f) \in \overline{\mathcal{A}}\) (since \(\mathcal{A}\) is an algebra containing constants, \(p_n(f)\) is a polynomial combination of powers of \(f\), which lie in \(\mathcal{A}\), and limits thereof lie in \(\overline{\mathcal{A}}\)). And \(\|p_n(f) - |f|\|_\infty \leq \|p_n - |\cdot|\|_{C([-M,M])} < 1/n \to 0\), so \(|f| \in \overline{\mathcal{A}}\).
Step 3: \(\overline{\mathcal{A}}\) is a lattice. From \(|f| \in \overline{\mathcal{A}}\): \[ \max(f, g) = \frac{f + g + |f - g|}{2}, \qquad \min(f, g) = \frac{f + g - |f-g|}{2}. \] Both lie in \(\overline{\mathcal{A}}\).
Step 4: Density. Fix \(f \in C(K)\) and \(\varepsilon > 0\). For any two points \(x, y \in K\), since \(\mathcal{A}\) separates points and contains constants, there exists \(h_{xy} \in \mathcal{A}\) with \(h_{xy}(x) = f(x)\) and \(h_{xy}(y) = f(y)\) (interpolate using a linear combination of a separating function and the constant function).
For fixed \(y\): the set \(U_{xy} = \{z \in K : h_{xy}(z) > f(z) - \varepsilon\}\) is open and contains \(x\). As \(x\) varies, \(\{U_{xy}\}_{x \in K}\) covers \(K\). Compactness gives a finite subcover; take \(h_y = \max(h_{x_1 y}, \ldots, h_{x_m y}) \in \overline{\mathcal{A}}\), which satisfies \(h_y > f - \varepsilon\) on all of \(K\) and \(h_y(y) = f(y)\).
For the upper bound: the set \(V_y = \{z : h_y(z) < f(z) + \varepsilon\}\) is open and contains \(y\). Cover \(K\) by finitely many \(V_{y_j}\), and set \(g = \min(h_{y_1}, \ldots, h_{y_\ell}) \in \overline{\mathcal{A}}\).
Then \(f - \varepsilon < g < f + \varepsilon\) on all of \(K\), so \(\|g - f\|_\infty < \varepsilon\). Since \(\varepsilon\) was arbitrary, \(f \in \overline{\mathcal{A}}\). \(\square\)
18.3 Consequences and examples
Corollary 18.1 (Polynomials are dense in \(C([a,b])\)) The algebra of polynomials separates points (\(p(x) = x\) distinguishes any two reals) and contains the constants. Stone–Weierstrass gives the Weierstrass theorem as a special case.
Corollary 18.2 (Trigonometric polynomials are dense in \(C([-\pi, \pi])\)) A trigonometric polynomial is a finite linear combination of \(1, \cos(nx), \sin(nx)\). The collection of trigonometric polynomials is a subalgebra of \(C([-\pi, \pi])\) (closed under products by the product-to-sum formulas), separates points, and contains the constants. Stone–Weierstrass applies.
This is the foundation of Fourier analysis: every continuous periodic function can be uniformly approximated by trigonometric polynomials. The \(L^2\) theory of Fourier series is a separate matter, but the density of trigonometric polynomials in \(C([-\pi, \pi])\) is the statement that matters for uniform approximation.
Corollary 18.3 (Polynomials are dense in \(C(K)\) for compact \(K\) subset \(\mathbb{R}^n\)) Polynomials in \(n\) variables separate points of \(K\) and form a subalgebra of \(C(K)\) containing the constants. Stone–Weierstrass applies.
Exercise. Let \(K = [0,1]^2\). Show that every continuous function on \(K\) can be uniformly approximated by polynomials in two variables. Explicitly: find a polynomial \(p(x,y)\) approximating \(f(x,y) = e^{xy}\) to within \(0.01\) on \(K\).
The corollary applies: polynomials in \(x\) and \(y\) form an algebra separating points of \([0,1]^2\) and containing the constants. For the explicit approximation: use the Taylor polynomial of \(e^{xy}\) around \(0\). Since \(|xy| \leq 1\) on \([0,1]^2\), the error in truncating at degree \(N\) is at most \(e/((N+1)!)\). For \(N = 5\): \(e/720 \approx 0.0038 < 0.01\). So \(p(x,y) = 1 + xy + (xy)^2/2 + (xy)^3/6 + (xy)^4/24 + (xy)^5/120\) works. \(\square\)
Exercise. Give an example of a subalgebra of \(C([0,1])\) that separates points but is not dense, and identify which hypothesis of Stone–Weierstrass it fails.
Let \(\mathcal{A} = \{f \in C([0,1]) : f(0) = 0\}\). This is a subalgebra (sums and products of functions vanishing at \(0\) vanish at \(0\)) and separates points (e.g. \(f(x) = x\) and \(f(x) = x^2\) give different values at any two distinct nonzero points; to separate \(0\) from \(y > 0\) note that no function in \(\mathcal{A}\) achieves a nonzero value at \(0\), but \(0\) is separated from \(y\) by the evaluation functionals). Wait — \(\mathcal{A}\) does separate points: for \(x \neq y\) both nonzero, use \(f(t) = t(t-y)\) or similar; for \(0 \neq y\), note \(f(y) \neq f(0) = 0\) is possible.
But \(\mathcal{A}\) does not contain the constants (\(f \equiv 1\) does not vanish at \(0\)). The constant function \(1 \in C([0,1])\) cannot be approximated uniformly by functions in \(\mathcal{A}\): any \(f \in \mathcal{A}\) satisfies \(f(0) = 0\), so \(\|f - 1\|_\infty \geq |f(0) - 1| = 1\). So \(\mathcal{A}\) is not dense — it fails the constants hypothesis. \(\square\)
18.4 The role of the real field
Stone–Weierstrass is a theorem about real-valued functions. The analogous statement for complex-valued functions on compact Hausdorff spaces requires an additional hypothesis: the algebra must also be closed under complex conjugation. The standard example of failure without this hypothesis is the algebra of analytic functions on the closed unit disc: the polynomials in \(z\) are dense in \(C(\partial \mathbb{D})\) only if one allows \(\bar{z}\) as well (the Weierstrass theorem for real variables does not apply to the complex setting without modification). This belongs to complex analysis.