A6 · Lesson 37 · Taylor's remainder
How many terms are enough?
A math library computing for single-precision floats needs about seven correct digits. It can't check its answer against the true value, because it doesn't have the true value; that's what it's computing. It needs a guarantee in advance: this many terms always gets within on this range. Taylor's theorem gives that guarantee. It says exactly what the error of a Taylor polynomial is, in a form you can bound without knowing the answer.
- The blue curve is ; the other is its Taylor polynomial of degree about 0.
- Raise . The polynomial hugs over a wider and wider range.
- At , the readouts show the actual error and the bound from Taylor's theorem. Is the actual error ever bigger than the bound?
Predict
Every derivative of is or , so none is ever bigger than 1 in size. What does that suggest about the error of its Taylor polynomials?
The error after the degree- polynomial is at most . The factorial in the denominator eventually crushes any power of , so for any fixed the error goes to zero; for large it just takes more terms. That's why the sine series converges everywhere.
Name it
Taylor's theorem
If has derivatives near , then , where is the Taylor polynomial of degree and the remainder is
for some between and . The remainder looks like the next term of the series, with the derivative evaluated at an unknown point instead of at .
The bound you can use
You don't know , but if everywhere between and , then
For and , . For on , (use 3 for if you like round numbers).
Even and odd functions get a bonus
The degree-3 polynomial of is also its degree-4 polynomial, since the term is zero. So you may use the remainder , giving the bound instead of . That's why the sim uses .
Keep small
The bound grows like , so libraries first reduce the range: using and other identities, they bring into or so, where a short polynomial is enough.
Worked example
Bound the error of .
Show the solution
- Write the remainder. This is , so the remainder is with .
- Bound it. Since ,
- Compare. The estimate is 1.625 and the true value is 1.6487, so the actual error is 0.024, inside the bound.
Answer the error is less than 0.042; the actual error is 0.024.
Worked example
What degree does a sine polynomial need for an error below on ?
Show the solution
- Write the bound. For an odd degree , the bound is
- Try degree 9. which is not enough.
- Try degree 11. which is below .
- What libraries do. Real libraries do better by reducing to and fine-tuning the coefficients, but this is the principle.
Answer degree 11, which is six nonzero terms.
Worked example
Estimate with the degree-3 Taylor polynomial about 1, and bound the error.
Show the solution
- Add three terms. Use with :
- Bound the remainder. It is with , at most 6 for :
- Compare. The true value is 0.182 32, so the actual error, 0.000 35, is just inside the bound.
Answer , with an error of at most 0.0004.
Check
You approximate with its Taylor polynomial of degree 3 about 0. Using as a bound on , what is the error bound?
Check
You approximate with its Taylor polynomial of degree 3. Using the bonus for odd functions, what is the error bound?
Check
You compute from its Taylor polynomial about 0, using the bound . What is the smallest degree that guarantees an error below 0.001?
Check
What is the actual error of ? (Use a calculator for .)
Check
For , . The second derivative is , which is at most in size. What is the error bound at = 0.2?
Check
Why does the Taylor series for converge for every , even ?
Check
Estimate with the degree-3 Taylor polynomial about 1.
(a)
What does it give?
(b)
What does the Lagrange remainder bound the error by? (.)
Check
Bound the Taylor error of the degree-3 polynomial for on .
Step 1
The remainder after degree 3 is . What is the largest can be for in ?
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
Write the bound.
Explain why
A Taylor polynomial is very accurate near its center and poor far away. Use the remainder formula to explain why.
The remainder is . Near the center, is small, and raising a small number to the power makes it tiny, so the error is very small and shrinks fast as you add terms. Far from the center, is large, so many terms are needed before the factorial in the denominator brings the error down. That's why libraries shrink the argument before using a series.
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.