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 near the point a, and the band is .
- The readout gives the largest δ such that every x within δ of a stays in the band: , set by the right side, where climbs faster.
- Move a further from 0: δ shrinks, about . That's why is continuous everywhere but not uniformly continuous on all of ℝ.
Predict
For at a = 2 with ε = 0.1, is the largest δ set by the left side or the right side of a?
The right side. rises faster to the right of 2 than it falls to the left, so it leaves the band first on the right, at . The left side would allow ; the right allows only 0.0248, and δ must work on both sides.
Name it
Bisection on δ
For a continuous f, "every x in satisfies " 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 . When f′ is monotone, bisection finds the unique c.
Bounds against actual errors
Taylor's theorem bounds the error by . Computing the actual error shows how much the bound overestimates. For a monotone function, exactly.
Truncating an improper integral
Split : compute the first numerically and the second exactly or by a bound. For the tail is exactly .
Worked example
Find the mean value point c for on [0, 2] by bisection.
Show the solution
- Slope of the chord. so c solves .
- Bisect. Since increases, bisect on [0, 2]: the bracket closes on
- Check against the exact answer. That's , the exact answer.
- 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 .
Worked example
Truncate at B = 1000 and add the exact tail.
Show the solution
- Integrate up to B. The trapezoid rule on [1, 1000] with two million intervals gives 0.992092.
- Add the exact tail. The tail beyond 1000 is so the total is 0.99999998.
- 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 at a = 1 with ε = 0.1?
Check
The degree-n Taylor polynomial of at 0 is used at x = 1, where (n + 1)! = 720. What is the Lagrange bound on its error?
Check
Write largest_delta(f, a, eps): bisect on δ in [0, 1] (100 steps), checking on 2001 points of . Set d for 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 equals the chord slope . 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 at x = 1, and bounds to the Lagrange bounds .
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 on [0, 1] with n equal strips. Set n_needed to the smallest n with U − L < .
Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.
Check
Compute with the trapezoid rule on 2 000 001 points (trunc), then add the exact tail (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 set by the side where the function climbs faster?
Continuity at a asks that every x within δ of a have f(x) within ε of f(a). The function leaves the ε band first on whichever side it changes faster, because there it needs less distance to change by ε. For with a > 0, the slope to the right of a is larger than to the left, so the band's upper edge is reached sooner going right: at , a distance away. A symmetric interval must fit the tighter side, so that distance is the largest δ. For functions that are steeper to the left, the left side sets it instead.
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.