A14 · Lesson 30 · Lab: sequences of functions in code
Sup norms, Bernstein rates, equicontinuity, M-test tails and radii of convergence
Lessons 25 to 29 dealt with sequences of functions: uniform convergence, what it preserves, power series, Weierstrass approximation and equicontinuity. Each comes down to measuring a sup norm or estimating a rate. In this lab you'll compute sup norms on fine grids and compare them with formulas, measure how fast Bernstein polynomials converge on a function with a corner, watch equicontinuity fail, compare the Weierstrass M-test's bound with the true tail, and estimate a radius of convergence from coefficients.
- The curve is the error of the degree-n Bernstein polynomial of , at its worst point , against n, on log axes.
- It falls like , much more slowly than for smooth functions, whose Bernstein error falls like (dashed, for ).
- The corner at ½ is what slows it: Bernstein polynomials average the function over a binomial spread of width about .
Predict
The Bernstein approximation of with n = 256 has error 0.025 at x = ½. About what n gives 0.0125?
About 1024: the error falls like , so halving it takes four times the degree. For a smooth function, doubling n would have been enough. Bernstein polynomials converge for every continuous function, but they don't speed up to match smoothness the way Chebyshev approximations do.
Name it
Sup norms on a grid
on [a, b] is approximated by the largest on a fine grid. For smooth f the grid estimate is accurate to about ; near sharp peaks use a finer grid or locate the peak exactly.
Bernstein polynomials in code
. math.comb gives the binomial coefficients. For large n, evaluate in floating point with care: the terms are a binomial distribution's probabilities.
Tails and radii
The Weierstrass M-test bounds the tail by ; the true sup of the tail is often smaller. A radius of convergence can be estimated from , but slowly: factors like in the coefficients contribute , which approaches 1 only gradually.
Worked example
Compare the grid sup of on [0, 1] with the formula, for n = 5, 10 and 50.
Show the solution
- Compute both. On 100 001 points, the grid maxima and the formula give:
| n | Grid maximum | Formula |
|---|---|---|
| 5 | 0.0669796 | 0.0669796 |
| 10 | 0.0350494 | 0.0350494 |
| 50 | 0.0072849 | 0.0072849 |
- Why they agree. They agree to the digits shown because the peak is smooth and the grid is fine.
- The trend. The decay, roughly , confirms the uniform convergence to 0 from lesson 25.
Answer the grid and the formula agree to the digits shown: 0.0669796, 0.0350494 and 0.0072849.
Worked example
Estimate the radius of convergence of from at k = 100 and k = 300.
Show the solution
- The root estimate.
- Evaluate it. At k = 100 that's 2.736 and at k = 300 it's 2.888.
- Why it's low. Both are still well below the true radius, 3, because approaches 1 slowly.
- Faster estimators. The root test is exact in the limit, but numerically it's a slow estimator. When the coefficients have a known form, ratios converge faster, and extrapolating in helps more.
Answer the estimate is 2.736 at k = 100 and 2.888 at k = 300, still well below the true radius, 3.
Check
About how large is the Bernstein error of at x = ½ for degree 100?
Check
What does give for at k = 100?
Check
Set sups to the grid maxima of on 100 001 points of [0, 1] for n = 5, 10, 50, and formula to for the same n.
Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.
Check
Write bern(f, n, xs) evaluating the degree-n Bernstein polynomial of f at the points xs (use math.comb). For , set errs to the largest errors on 401 points of [0, 1] for n = 16, 64, 256.
Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.
Check
For at x = 1 with ε = ½, the largest δ is . Set deltas for n = 10, 100, 1000, and prod to n times δ for n = 1000.
Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.
Check
Compare the M-test bound with the actual tail of . On 2001 points of [0, 2π], set actual to the largest and bound to , the bound from .
Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.
Check
Set r100 and r300 to for at k = 100 and 300.
Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.
Explain why
Why do Bernstein polynomials converge slowly near a corner?
The Bernstein polynomial at x is an average of the function's values at the points , weighted by the binomial probabilities for n trials with success probability x. Those weights spread over a width of about around x. For a smooth function, averaging over that width changes the value by an amount proportional to the curvature times the variance, about . At a corner the function isn't locally linear, so the average differs from the value by an amount proportional to the width itself, about . Halving the error then needs four times the degree.
Practice
Keep practicing
4 kinds of problem on this topic, dealt one at a time with new numbers every time, for as long as you like.