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

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 |x−12|, at its worst point x=12, against n, on log axes.
  • It falls like 12πn, much more slowly than for smooth functions, whose Bernstein error falls like 1n (dashed, for x2).
  • The corner at ½ is what slows it: Bernstein polynomials average the function over a binomial spread of width about 12n.

Predict

The Bernstein approximation of |x−12| with n = 256 has error 0.025 at x = ½. About what n gives 0.0125?

Name it

Sup norms on a grid

‖f‖∞ on [a, b] is approximated by the largest |f| on a fine grid. For smooth f the grid estimate is accurate to about h2max⁡|f′′|/8; near sharp peaks use a finer grid or locate the peak exactly.

Bernstein polynomials in code

Bnf(x)=∑k=0nf(kn)(nk)xk(1−x)n−k. 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 ∑k>N by ∑k>NMk; the true sup of the tail is often smaller. A radius of convergence can be estimated from |ck|−1/k, but slowly: factors like k2 in the coefficients contribute k−2/k, which approaches 1 only gradually.

Worked example

Compare the grid sup of xn(1−x) on [0, 1] with the formula, for n = 5, 10 and 50.

Show the solution
  1. Compute both. On 100 001 points, the grid maxima and the formula 1n+1(nn+1)n give:
nGrid maximumFormula
50.06697960.0669796
100.03504940.0350494
500.00728490.0072849
  1. Why they agree. They agree to the digits shown because the peak is smooth and the grid is fine.
  2. The trend. The decay, roughly 1e(n+1), 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 ∑k2xk3k from |ck|−1/k at k = 100 and k = 300.

Show the solution
  1. The root estimate. ck−1/k=3k−2/k
  2. Evaluate it. At k = 100 that's 2.736 and at k = 300 it's 2.888.
  3. Why it's low. Both are still well below the true radius, 3, because k−2/k=e−2ln⁡k/k approaches 1 slowly.
  4. 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 ckck+1=3(kk+1)2 converge faster, and extrapolating in 1k 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 |x−12| at x = ½ for degree 100?

Check

What does |ck|−1/k give for ck=k23k at k = 100?

Check

Set sups to the grid maxima of xn(1−x) on 100 001 points of [0, 1] for n = 5, 10, 50, and formula to 1n+1(nn+1)n 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 f=|x−12|, 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 xn at x = 1 with ε = ½, the largest δ is 1−2−1/n. 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 ∑sin⁡kxk2. On 2001 points of [0, 2π], set actual to the largest |∑k=515000sin⁡kxk2| and bound to 150, the bound from ∑k>N1k2<1N.

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 ck−1/k for ck=k23k 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?

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.