Taylor and Maclaurin Series with Error Bounds
Learning Objectives
- Build the Taylor polynomial and the Taylor series of a function at a point , and the Maclaurin series when .
- State Taylor's theorem with the Lagrange remainder, including its hypotheses, and use with taken over the whole interval between and .
- Compute how many terms a target accuracy requires, and check that the bound holds against the true error.
- Explain why a Taylor series can converge without converging to the function, and why it can fail to converge where the function is perfectly defined.
- Choose between expansions (or around different centers) to reach an accuracy with far fewer terms.
Context & Motivation
A computer can add, subtract, multiply, and divide. Everything else, such as , , or , has to be reduced to those four operations, and the natural way is a polynomial. A Taylor polynomial is the polynomial that matches a function and its first derivatives at one point. The degree-1 version is the tangent line, the linearization behind gradient-based optimization. The degree-2 version adds curvature, which is the local model behind Newton's method for minimization.
Approximating without knowing the error is guessing. This lesson's real subject is the remainder: a bound on that depends only on the derivatives of and so can be computed before the approximation is ever evaluated. The bound turns "how many terms do I need?" into an inequality that can be solved. It builds directly on power-series-and-the-radius-of-convergence: the Taylor series of a function is a power series, so it has a radius, and its behavior at the endpoints follows the tests of convergence-tests.
Core Theory
Taylor polynomials and series
Suppose has derivatives of all orders at . The Taylor polynomial of degree at is
and the Taylor series is the series whose partial sums are these polynomials. It is defined by its coefficients alone; whether it converges at a given is a separate question. At it is called the Maclaurin series. The coefficients are forced by the requirement that match and its first derivatives at , which is the same formula that term-by-term differentiation gave in the previous lesson. The error is .
Taylor's theorem and the Lagrange remainder
Hypotheses. is continuous on the closed interval between and , and exists on the open interval inside it. Conclusion. There is a number strictly between and such that
The point is not known, so the theorem is used through a bound. If for all in , then
The value must bound the derivative on the whole interval between and , not just at . The case is the Mean Value Theorem, (see the-mean-value-theorem-and-monotonicity), so Taylor's theorem is its higher-order generalization.
When the series equals the function
The Taylor series converges to exactly when . Both parts can fail separately.
For every derivative is , so works for any and , because factorials outgrow exponentials. The same argument with works for and . These three series therefore equal their functions on all of .
Convergence of the series alone does not settle it. The function for , with , has for every (Example 4). Its Maclaurin series is identically , so it converges everywhere, and it equals only at . The function is infinitely differentiable but not equal to its Taylor series.
The series can also stop short of the function's domain. is defined for all , but its Maclaurin series has radius and diverges at .
Standard Maclaurin series
- : , converging to the function for all real .
- : , converging to the function for all real .
- : , converging to the function for all real .
- : , converging to the function for .
- : , converging to the function for .
- : , converging to the function for .
The last three are the ones where endpoints matter. For the endpoint is included and is excluded (it gives ).
Three ways to bound an error
- Lagrange bound, as above, for any smooth function.
- Alternating series bound, , when the terms alternate and decrease to (see
convergence-tests). It needs no derivatives. - Geometric tail bound, when terms are dominated by a ratio : the sum of the terms from on is at most if each term is at most times the previous one.
How many terms are needed
Fix the tolerance , the point , and a bound . The smallest with guarantees the accuracy. It is a guarantee, not a prediction: the true error is often several times smaller.
Worked Examples
Example 1: to six decimals, and a wrong
Approximate with the Maclaurin polynomial at , , tolerance . On every derivative of is at most , so take . Then . Because and , the first that works is , that is, . A script compares the bound with the actual error :
textn bound 3/(n+1)! actual error 7 7.44e-05 2.79e-05 8 8.27e-06 3.06e-06 9 8.27e-07 3.03e-07 10 7.52e-08 2.73e-08
The bound holds for every (a script confirms it for in 80-digit arithmetic), and here it is about times too large. Here really does miss the target: its actual error is . If had been used, taking instead of the maximum on , the bound would read at , smaller than the actual error . A wrong is not just loose; it is false.
Example 2: to ten decimals
With (any derivative of is or ), . We need , which first happens at ( is too small, is enough). Hence , and against , with actual error and bound . The bound is loose by a factor of because the Taylor polynomial of has no even terms, so and the bound with gives , the actual error to two digits. The bound is only as sharp as the it is applied with.
Example 3: the same number, far fewer terms ( and )
The series at gives , and the alternating bound is . Reaching would take about terms. (The Lagrange bound agrees: on the maximum of is , giving .) A smarter route subtracts the series for to get
Taking gives . Each term is smaller than the previous by at least a factor of , so the tail after terms is at most . This is below at (bound , actual error ), against terms before. Ten terms instead of ten billion: the form of the expansion matters more than the number of terms.
Changing the center helps in the same way. To get to within from the Maclaurin series, the bound first drops below at (bound , actual error ). Expanding at instead, where is small, the bound is below already at (bound , actual error ). The polynomial is with , because . Four nonzero terms replace eleven.
Example 4: a function not equal to its Taylor series
Let for and . For every , is a sum of terms of the form with a polynomial, and goes to faster than any power of , so (a script verifies this by limits for ). The Maclaurin series is . But and . The series converges at every , to the wrong value. In Taylor's theorem terms: for all , and it never tends to .
Example 5: where the bound is useless
For at (outside the radius), on , giving , which grows without bound, and the partial sums confirm it: , , , , while . The bound is not merely weak; the series genuinely diverges, because the terms do not tend to . At , by contrast, the same bound is at , with actual error .
Example 6: Taylor is not what libraries use ("book vs today")
A degree-7 Taylor polynomial for on has maximum error , at the ends, matching the Lagrange bound (using since ). A polynomial interpolating at 9 Chebyshev nodes (degree 8, which reduces to degree 7 for an odd function) has maximum error on the same interval. The best possible degree-7 polynomial (minimax) has maximum error about , found by linear programming on a fine grid, with an error curve that equioscillates at five points as the theory requires. The Taylor polynomial is therefore about 270 times worse than the best polynomial of its degree. Taylor polynomials are exact at a single point and degrade away from it. Production math libraries typically combine range reduction with polynomials fitted to minimize the worst-case error over the whole interval, which is a refinement of the idea in this lesson and not a repeal of it.
Common Misconceptions & Pitfalls
- "The Taylor series of always equals ." Example 4 is infinitely differentiable and has a Taylor series that equals it only at one point. Equality needs .
- "If the function is defined at , the Taylor series converges there." at is the counterexample (Example 5); the radius of the series is the limit.
- "Take from the derivative at the center." must bound the derivative on the whole interval between and . Example 1 shows a bound that is smaller than the true error.
- "The bound is the error." It is an upper bound; the true error is often several times smaller. Do not report it as an estimate.
- "More terms always help." Outside the interval of convergence they make things worse (Example 5), and inside it, precision and floating-point rounding limit what is gained.
- "The bound covers all the error." The Lagrange bound covers truncation only. A floating-point evaluation has its own rounding error, which this lesson does not bound.
Summary
The Taylor polynomial matches and its first derivatives at , and the Taylor series is the series whose partial sums they are. Taylor's theorem, valid when is continuous on the interval and exists inside it, gives the remainder and the bound , with over the whole interval. Solving that bound for answers "how many terms", and a script can confirm the bound against the true error. The series equals the function only where : this holds for , and everywhere, for on , and fails for the flat function at every . Choosing the expansion or the center well, as for with and at , can matter far more than adding terms.