Weierstrass Approximation Theorem

lean4-proofcalculusvisualization
ε>0  pR[x]:  supx[a,b]f(x)p(x)<ε\forall\varepsilon>0\;\exists p\in\mathbb{R}[x]:\;\sup_{x\in[a,b]}|f(x)-p(x)|<\varepsilon

Statement

Let f:[a,b]Rf : [a, b] \to \mathbb{R} be continuous. For every ε>0\varepsilon > 0 there exists a polynomial pR[x]p \in \mathbb{R}[x] such that

supx[a,b]f(x)p(x)<ε\sup_{x \in [a,b]} |f(x) - p(x)| < \varepsilon

Equivalently, the polynomials are dense in C([a,b])C([a,b]) with the uniform norm f=sup[a,b]f\|f\|_\infty = \sup_{[a,b]} |f|.

Visualization

Bernstein polynomials BnfB_n f approximate f(x)=xf(x) = |x| on [1,1][-1, 1] uniformly. Explicitly, reparameterizing to [0,1][0,1] with g(t)=2t1g(t) = |2t-1|:

Bng(t)=k=0ng ⁣(kn)(nk)tk(1t)nkB_n g(t) = \sum_{k=0}^{n} g\!\left(\frac{k}{n}\right) \binom{n}{k} t^k (1-t)^{n-k}

| xx | f(x)=xf(x) = |x| | B4B_4 | B8B_8 | B16B_{16} | |-----|------------|-------|-------|--------| | 0.0 | 0.000 | 0.375 | 0.273 | 0.196 | | 0.2 | 0.200 | 0.261 | 0.231 | 0.214 | | 0.5 | 0.500 | 0.500 | 0.500 | 0.500 | | 0.8 | 0.800 | 0.761 | 0.781 | 0.791 | | 1.0 | 1.000 | 1.000 | 1.000 | 1.000 |

(Values computed for g(t)=2t1g(t) = |2t-1| on [0,1][0,1], so t=(x+1)/2t = (x+1)/2.)

The uniform error Bngg=O(n1/2)\|B_n g - g\|_\infty = O(n^{-1/2}) for Lipschitz gg; higher-degree polynomials converge to x|x| everywhere.

  Approximation of |x| by polynomials on [-1,1]

  1 |*         *   ← |x|
    | *\     /*
    |  *\   /* ← B₄ (smoothed corners)
    |   *\ /* ← B₈
  0 |----*------   ← x=0, f(0)=0, B_n(0)→0
    |   /* \*
    |  /    \* ← converging to |x|
   -1                   1

Proof Sketch

  1. Bernstein polynomials: For fC([0,1])f \in C([0,1]) define Bnf(x)=k=0nf(k/n)(nk)xk(1x)nkB_n f(x) = \sum_{k=0}^{n} f(k/n) \binom{n}{k} x^k (1-x)^{n-k}.
  2. Probabilistic identity: Bnf(x)=E[f(Sn/n)]B_n f(x) = \mathbb{E}[f(S_n/n)] where SnBinomial(n,x)S_n \sim \mathrm{Binomial}(n, x). By the law of large numbers Sn/nxS_n/n \to x, so Bnf(x)f(x)B_n f(x) \to f(x).
  3. Uniform convergence: Continuity on the compact set [0,1][0,1] implies uniform continuity. The estimate Bnf(x)f(x)ωf(δ)+2f/(nδ2)|B_n f(x) - f(x)| \leq \omega_f(\delta) + 2\|f\|_\infty / (n\delta^2) (where ωf\omega_f is the modulus of continuity) gives uniform convergence by choosing δ=n1/4\delta = n^{-1/4}.
  4. General [a,b][a,b]: Apply the [0,1][0,1] result after the affine reparameterization t=(xa)/(ba)t = (x-a)/(b-a).

Connections

  • Extreme Value TheoremExtreme Value TheoremfC(K),K compact    x,xK:  f(x)=minf=f(x)maxff\in C(K),\,K\text{ compact}\implies\exists\,x_*,x^*\in K:\;f(x_*)=\min f=f(x^*)\leq\max fA continuous function on a compact set attains its maximum and minimum valuesRead more →ff is uniformly continuous on [a,b][a,b] (since it is compact) — this is the key regularity that makes the Bernstein approximation converge
  • Heine-Borel Theorem — the compact domain [a,b][a,b] is essential; the theorem fails for all of R\mathbb{R} (polynomials cannot uniformly approximate exe^x)
  • Intermediate Value TheoremIntermediate Value Theoremf(a)yf(b)c[a,b]:  f(c)=yf(a) \le y \le f(b) \Rightarrow \exists\, c \in [a,b]:\; f(c) = yA continuous function on a closed interval hits every value between its endpointsRead more → — the density of polynomials in C[a,b]C[a,b] is the analytic analogue of the IVT: every continuous function is a limit of explicit elementary ones
  • Stone–Weierstrass TheoremStone–Weierstrass TheoremAC(X) sep. pts, contains 1A=C(X)A \subseteq C(X) \text{ sep. pts, contains 1} \Rightarrow \overline{A} = C(X)A subalgebra of continuous functions on a compact space that separates points is dense in the sup-normRead more → — the functional-analysis generalization: any subalgebra of C(K)C(K) that separates points and contains constants is dense; Weierstrass is the case where the subalgebra is R[x]\mathbb{R}[x] on [a,b][a,b]

Lean4 Proof

import Mathlib.Topology.ContinuousMap.Weierstrass

/-- Weierstrass Approximation Theorem: polynomials are dense in C([a,b]).
    Wraps Mathlib's `polynomialFunctions_closure_eq_top`. -/
theorem weierstrass_approximation (a b : ) :
    (polynomialFunctions (Set.Icc a b)).topologicalClosure = ⊤ :=
  polynomialFunctions_closure_eq_top a b