A1428 of 55
0 XP
  1. Hook
  2. Play
  3. Predict
  4. Name it
  5. Check
  6. Explain

A14 · Lesson 28 · The Weierstrass approximation theorem

Every continuous function on an interval is nearly a polynomial

Polynomials are what computers evaluate best: a few multiplications and additions. The Weierstrass approximation theorem guarantees they're enough: any continuous function on a closed interval can be approximated by a polynomial to any accuracy you want, uniformly, at every point at once. Bernstein's proof is constructive and has a probabilistic heart: average the function's values at k/n with binomial weights, and the law of large numbers does the rest. It's slow in practice, but the theorem is why polynomial and Chebyshev approximations in function libraries, filter design and sensor calibration can always succeed.

  • The solid curve is cos⁡(ωx) on [0, 1]. The dashed one is its Bernstein polynomial of degree n, Bnf(x)=∑k=0nf(kn)(nk)xk(1−x)n−k.
  • Raise n: the polynomial closes in everywhere at once, but slowly. The error behaves like ‖f′′‖8n (readout), so 10 times the degree buys only 10 times the accuracy.
  • Raise ω: the function wiggles more, f″ is larger, and much higher degree is needed.

Predict

The Bernstein polynomial of f(x)=x2 is Bnf(x)=x2+x(1−x)n. What's its largest error on [0, 1]?

Name it

The theorem

If f is continuous on [a, b], then for every ε > 0 there's a polynomial p with |f(x)−p(x)|<ε for all x in [a, b].

Bernstein's proof

On [0, 1], let Bnf(x)=∑k=0nf(k/n)(nk)xk(1−x)n−k. The weights are the binomial probabilities for n trials with success probability x, so Bnf(x) is the expected value of f(K/n) with K the number of successes. As n grows, K/n concentrates near x (its variance is x(1−x)n), and uniform continuity of f makes f(K/n) close to f(x). For f with a bounded second derivative,

|Bnf(x)−f(x)|≤‖f′′‖∞x(1−x)2n≤‖f′′‖∞8n

Bernstein polynomials keep the endpoint values (Bnf(0)=f(0), Bnf(1)=f(1)), reproduce straight lines exactly, and never overshoot: if f is between m and M, so is Bnf.

In practice

For a smooth function, Chebyshev interpolation (A13, lesson 11) or the minimax polynomial converge far faster, often exponentially, which is how library functions like sin and exp are computed. Stone–Weierstrass generalizes the theorem: trigonometric polynomials approximate any continuous periodic function uniformly, for instance by the averaged (Fejér) Fourier sums of lesson 40.

Worked example

What degree n of Bernstein polynomial approximates x2 to within 0.001 everywhere on [0, 1]?

Show the solution
  1. The largest error. For x2 it is 14n.
  2. Solve for n. That's below 0.001 when n > 250, so n = 251.
  3. Compare with interpolation. A degree-2 interpolating polynomial would be exact, which shows how conservative Bernstein's method is.

Answer degree n = 251.

Worked example

Bound the Bernstein error for cos⁡5x with n = 50.

Show the solution
  1. Size of the second derivative. ‖f′′‖∞=25
  2. Bound the error. With n = 50, ‖f′′‖∞8n=25400=0.0625
  3. Compare with the actual error. Evaluating on a fine grid gives 0.058: the bound is nearly tight.

Answer the error is at most 0.0625, and it's actually 0.058.

Worked example

Compute the Bernstein polynomial of x3 of degree 2 at x=12, and the general error.

Show the solution
  1. Write out B2. B2(x3)(x)=∑k=02(k2)3(2k)×xk(1−x)2−k=18⋅2x(1−x)+x2
  2. Put in x = ½. 0.0625+0.25=0.3125 against the true 0.125.
  3. The general error. Bn(x3)=x3+3x2(1−x)n+x(1−x)(1−2x)n2 so the error falls as 1n.
  4. What it shows. Bernstein polynomials converge for every continuous function, but slowly. That's the price of a construction that works without any smoothness at all.

Answer B2(x3) is 0.3125 at ½, against the true 0.125, and in general the error falls as 1n.

Check

What's the largest error of the degree-100 Bernstein polynomial of x2 on [0, 1]?

Check

Smallest Bernstein degree that approximates x2 within 0.0023 everywhere on [0, 1]?

Check

Bound the Bernstein error for cos⁡(5x) on [0, 1] with degree 20.

Check

The Bernstein polynomial of ex has the closed form (1−x+xe1/n)n. What's its value at x = 0.3 for n = 5?

Check

What's the Bernstein polynomial of f(x)=2x+1, of any degree, at x = 0.8?

Check

Why does Bnf(x)→f(x)?

Check

The Bernstein polynomial of x3 is Bn=x3+3x2(1−x)n+x(1−x)(1−2x)n2.

(a)

What is B2 at x = 0.25?

(b)

What is its error there?

Check

The Bernstein polynomial of x2.

Step 1

What is Bn(x2)?

Type it the way you would write it, like 3sin(2πft) or 3*sin(2*pi*f*t). Angles can be in radians or carry a degree sign, like 45°.

Explain why

How does the law of large numbers prove that polynomials can approximate any continuous function?

Practice

Keep practicing

9 kinds of problem on this topic, dealt one at a time with new numbers every time, for as long as you like.