---
tag: 1P8D3MK79H
kind: statement
role: theorem
name: Stone–Weierstrass theorem
msc: [46J10, 41A65, 54C35]
uses: [0TVJZYB6SH, 0S1FJ8VEX9, 0PARCKE8WP, 0BSJSX7ME2, 0JQE130DHW]
about: [MG3X8Y1VT4]
sources:
  - url: https://en.wikipedia.org/wiki/Stone%E2%80%93Weierstrass_theorem
same_as:
  wikidata: Q939927
  wikipedia: Stone–Weierstrass theorem
---

## Statement

Let $X$ be a [[compact|0TVJZYB6SH]] [[Hausdorff space|0S1FJ8VEX9]].
Let $C(X, \R)$ be the space of continuous real functions on $X$ with the [[supremum norm|0PARCKE8WP]].
Let $A \subseteq C(X, \R)$ be a subalgebra with these two properties.

1. $A$ contains the constant functions.
2. $A$ separates points: for all $x \ne y$ in $X$ there is $f \in A$ with $f(x) \ne f(y)$.

Then $A$ is [[dense|0BSJSX7ME2]] in $C(X, \R)$.

## Remarks

The idea of the proof: the closure $\bar{A}$ is again an algebra.
By the [[Weierstrass approximation theorem|0JQE130DHW]], $\abs{t}$ is a uniform limit of polynomials on each interval, so $f \in \bar{A}$ implies $\abs{f} \in \bar{A}$.
Hence $\bar{A}$ is closed under $\max$ and $\min$.
A compactness argument then approximates any continuous function by finite maxima and minima of functions in $\bar{A}$.

Examples: polynomials in $n$ variables are dense in $C(K, \R)$ for each compact $K \subset \R^n$.
Trigonometric polynomials are dense in the continuous $2\pi$-periodic functions.

Both hypotheses are needed.
On $[-1, 1]$, the even polynomials form an algebra with constants, but it does not separate $1$ from $-1$, and $x$ is not a uniform limit of even functions.
The functions $f$ with $f(0) = 0$ separate points but miss the constants.

For complex functions, $A$ must also be closed under complex conjugation.
On the unit circle, the polynomials in $z$ separate points but are not dense: $\bar{z}$ is not a uniform limit of them.

## Explanations

### L1 human

You can approximate any continuous function on a compact space as closely as you like, provided your building blocks can tell points apart and include the constants.
This is a far-reaching form of Weierstrass's result that polynomials approximate continuous functions on an interval.

### L2 human

The theorem is the standard way to prove that a class of functions is dense in $C(X)$.
It gives density of polynomials, of trigonometric polynomials, and of sums of products $f(x) g(y)$ in $C(X \times Y)$.
In the theory of C*-algebras it is the main tool behind the commutative Gelfand–Naimark theorem.
