Mathwords logoMathwords

Weierstrass Approximation Theorem — Definition, Formula & Example

The Weierstrass Approximation Theorem is the result that any continuous function on a closed, bounded interval can be matched as closely as you like by a polynomial, with the same error bound holding at every point of the interval at once.

Let f:[a,b]→Rf:[a,b]\to\mathbb{R} be continuous. For every ε>0\varepsilon>0 there exists a polynomial pp with real coefficients such that ∣f(x)−p(x)∣<ε|f(x)-p(x)|<\varepsilon for all x∈[a,b]x\in[a,b]. Equivalently, the polynomials are dense in C[a,b]C[a,b] under the sup norm ∥g∥∞=sup⁡x∈[a,b]∣g(x)∣\|g\|_\infty=\sup_{x\in[a,b]}|g(x)|.

Key Formula

Bnf(x)=∑k=0nf ⁣(kn)(nk)xk(1−x)n−k,lim⁡n→∞ sup⁡x∈[0,1]∣Bnf(x)−f(x)∣=0B_n f(x)=\sum_{k=0}^{n} f\!\left(\frac{k}{n}\right)\binom{n}{k}x^k(1-x)^{n-k}, \qquad \lim_{n\to\infty}\,\sup_{x\in[0,1]}\left|B_n f(x)-f(x)\right|=0
Where:
  • ff = A continuous function on [0,1][0,1]
  • nn = Degree of the Bernstein polynomial, a positive integer
  • kk = Summation index; ff is sampled at the points k/nk/n
  • (nk)xk(1−x)n−k\binom{n}{k}x^k(1-x)^{n-k} = Bernstein basis polynomial, the binomial probability of exactly kk successes

How It Works

The substitution x=a+(b−a)tx=a+(b-a)t reduces the problem to the interval [0,1][0,1]. Bernstein's proof (1912) builds explicit polynomials BnfB_n f by sampling ff at k/nk/n and weighting the samples with binomial probabilities. Uniform continuity of ff handles the sample points near xx. A variance bound shows that points far from xx carry little weight. Weierstrass's original 1885 proof instead smoothed ff by convolving it with a narrow Gaussian kernel and then truncated that function's Taylor series.

Worked Example

Problem: Use Bernstein polynomials to approximate f(x)=x2f(x)=x^2 on [0,1][0,1]. Find the smallest degree nn for which the Bernstein bound guarantees an error of at most 0.010.01 at every point.
Step 1: Compute BnfB_n f. Treat kk as a binomial count with mean nxnx and variance nx(1−x)nx(1-x). Then E[k2]=nx(1−x)+n2x2E[k^2]=nx(1-x)+n^2x^2. Divide by n2n^2.
Bnf(x)=∑k=0n(kn)2(nk)xk(1−x)n−k=x2+x(1−x)nB_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}
Step 2: Bound the error uniformly. The product x(1−x)x(1-x) is largest at x=12x=\tfrac12, where it equals 14\tfrac14.
∣Bnf(x)−x2∣=x(1−x)n≤14n\left|B_n f(x)-x^2\right|=\frac{x(1-x)}{n}\le\frac{1}{4n}
Step 3: Require the worst-case error to be at most 0.010.01 and solve for nn.
14n≤0.01  ⟺  n≥25\frac{1}{4n}\le 0.01 \iff n\ge 25
Answer: The smallest such degree is n=25n=25. The polynomial B25f(x)=x2+x(1−x)25B_{25}f(x)=x^2+\frac{x(1-x)}{25} is within 0.010.01 of x2x^2 on all of [0,1][0,1]. The largest error is exactly 0.010.01, at x=12x=\tfrac12. Because the bound 14n\frac{1}{4n} goes to 00, the convergence is uniform, as the theorem promises.

Why It Matters

In numerical analysis, this theorem is the reason you can replace any continuous function with a polynomial and then evaluate, integrate, or interpolate it cheaply. Its generalization, the Stone–Weierstrass Theorem, shows that trigonometric polynomials are dense, which underpins Fourier analysis. The Bernstein basis from the proof is the same basis that defines Bézier curves in computer graphics and CAD software.

Common Mistakes

Mistake: Assuming the approximating polynomials are Taylor polynomials, or that ff must be differentiable.
Correction: The theorem needs only continuity. It even applies to nowhere-differentiable functions, which have no Taylor series at all. The interval must also be closed and bounded. On (0,1)(0,1), the function f(x)=1/xf(x)=1/x is unbounded, so no polynomial can stay within any fixed ε\varepsilon of it.

Related Terms