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 on [0, 1]. The dashed one is its Bernstein polynomial of degree n, .
- Raise n: the polynomial closes in everywhere at once, but slowly. The error behaves like (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 is . What's its largest error on [0, 1]?
, at x = ½, where is largest. The error falls only as , even for a function as smooth as : Bernstein polynomials prove the theorem but aren't how you'd build an approximation in practice.
Name it
The theorem
If f is continuous on [a, b], then for every ε > 0 there's a polynomial p with for all x in [a, b].
Bernstein's proof
On [0, 1], let . The weights are the binomial probabilities for n trials with success probability x, so is the expected value of with K the number of successes. As n grows, K/n concentrates near x (its variance is ), and uniform continuity of f makes close to f(x). For f with a bounded second derivative,
Bernstein polynomials keep the endpoint values (, ), reproduce straight lines exactly, and never overshoot: if f is between m and M, so is .
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 to within 0.001 everywhere on [0, 1]?
Show the solution
- The largest error. For it is .
- Solve for n. That's below 0.001 when n > 250, so n = 251.
- 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 with n = 50.
Show the solution
- Size of the second derivative.
- Bound the error. With n = 50,
- 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 of degree 2 at , and the general error.
Show the solution
- Write out .
- Put in x = ½. against the true 0.125.
- The general error. so the error falls as .
- 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 is 0.3125 at ½, against the true 0.125, and in general the error falls as .
Check
What's the largest error of the degree-100 Bernstein polynomial of on [0, 1]?
Check
Smallest Bernstein degree that approximates within 0.0023 everywhere on [0, 1]?
Check
Bound the Bernstein error for on [0, 1] with degree 20.
Check
The Bernstein polynomial of has the closed form . What's its value at x = 0.3 for n = 5?
Check
What's the Bernstein polynomial of , of any degree, at x = 0.8?
Check
Why does ?
Check
The Bernstein polynomial of is .
(a)
What is at x = 0.25?
(b)
What is its error there?
Check
The Bernstein polynomial of .
Step 1
What is ?
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°.
Step 2
What is its largest error on [0, 1]?
Explain why
How does the law of large numbers prove that polynomials can approximate any continuous function?
Toss a coin with heads probability x, n times, and let K be the number of heads. Then K/n is close to x with high probability: its variance is , which shrinks as n grows. The Bernstein polynomial is exactly the average of over this experiment, and it's a polynomial in x because each binomial probability is. Where K/n is near x, is near f(x) by uniform continuity; the chance that K/n is far from x is small, and f is bounded, so those cases contribute little. Together they make uniformly close to f for large n.
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.