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

A14 · Lesson 22 · Lab: limits, derivatives and integrals in code

Largest δ, mean value points, Taylor bounds, Riemann sums and improper tails

Lessons 11 to 20 proved the theorems of one-variable calculus: continuity with ε and δ, the mean value theorem, Taylor's theorem with remainder, the Riemann integral and improper integrals. Each theorem promises a number exists or a bound holds. In this lab you'll compute those numbers. You'll find the largest δ by bisection, locate a mean value point, compare Taylor errors with their bounds, find how many strips squeeze the upper and lower sums together, and evaluate an improper integral by truncating it and adding an exact tail.

  • The curve is x2 near the point a, and the band is f(a)±ε.
  • The readout gives the largest δ such that every x within δ of a stays in the band: a2+ε−a, set by the right side, where x2 climbs faster.
  • Move a further from 0: δ shrinks, about ε2a. That's why x2 is continuous everywhere but not uniformly continuous on all of ℝ.

Predict

For x2 at a = 2 with ε = 0.1, is the largest δ set by the left side or the right side of a?

Name it

Bisection on δ

For a continuous f, "every x in (a−δ,a+δ) satisfies |f(x)−f(a)|<ε" is true for small δ and false past the largest one, so bisection finds it. Checking the condition on a fine grid is an approximation, good enough for smooth f.

Locating a mean value point

For f differentiable on [a, b], solve f′(c)=f(b)−f(a)b−a. When f′ is monotone, bisection finds the unique c.

Bounds against actual errors

Taylor's theorem bounds the error by M|x−a|n+1(n+1)!. Computing the actual error shows how much the bound overestimates. For a monotone function, U−L=|f(b)−f(a)|(b−a)n exactly.

Truncating an improper integral

Split ∫1∞=∫1B+∫B∞: compute the first numerically and the second exactly or by a bound. For ln⁡xx2 the tail is exactly ln⁡B+1B.

Worked example

Find the mean value point c for ex on [0, 2] by bisection.

Show the solution
  1. Slope of the chord. e2−12=3.1945 so c solves ec=3.1945.
  2. Bisect. Since ec increases, bisect on [0, 2]: the bracket closes on c=1.161439
  3. Check against the exact answer. That's ln⁡e2−12, the exact answer.
  4. Why bisection helps. For a function whose derivative can't be inverted by formula, bisection still works, and the theorem guarantees there's something to find.

Answer c = 1.161439, which is ln⁡e2−12.

Worked example

Truncate ∫1∞ln⁡xx2dx at B = 1000 and add the exact tail.

Show the solution
  1. Integrate up to B. The trapezoid rule on [1, 1000] with two million intervals gives 0.992092.
  2. Add the exact tail. The tail beyond 1000 is ln⁡1000+11000=0.007908 so the total is 0.99999998.
  3. Compare with the exact value. The exact value is 1. Truncating alone leaves an error of 0.8%: slowly decaying integrands need their tails handled analytically, rather than by a larger B.

Answer 0.992092 plus the tail 0.007908 gives 0.99999998, against the exact value 1.

Check

What is the largest δ for x2 at a = 1 with ε = 0.1?

Check

The degree-n Taylor polynomial of ex at 0 is used at x = 1, where (n + 1)! = 720. What is the Lagrange bound e(n+1)! on its error?

Check

Write largest_delta(f, a, eps): bisect on δ in [0, 1] (100 steps), checking max⁡|f(x)−f(a)|<ε on 2001 points of [a−δ,a+δ]. Set d for x2 at a = 2, ε = 0.1.

Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.

Check

Find by bisection the point c in (0, 2) where ec equals the chord slope e2−12. Set c.

Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.

Check

For n = 1 to 8, set errs to the actual errors of the degree-n Taylor polynomial of ex at x = 1, and bounds to the Lagrange bounds e(n+1)!.

Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.

Check

Write UL(n) returning the upper and lower sums of e−x on [0, 1] with n equal strips. Set n_needed to the smallest n with U − L < 10−3.

Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.

Check

Compute ∫11000ln⁡xx2dx with the trapezoid rule on 2 000 001 points (trunc), then add the exact tail ln⁡1000+11000 (total).

Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.

Explain why

Why is the largest δ for x2 set by the side where the function climbs faster?

Practice

Keep practicing

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