Taylor and Maclaurin Series with Error Bounds

Published on 2026-11-04·v1.0

Learning Objectives

  • Build the Taylor polynomial TnT_n and the Taylor series of a function at a point aa, and the Maclaurin series when a=0a = 0.
  • State Taylor's theorem with the Lagrange remainder, including its hypotheses, and use ∣Rn∣≤M∣x−a∣n+1/(n+1)!\lvert R_n\rvert \le M\lvert x-a\rvert^{n+1}/(n+1)! with MM taken over the whole interval between aa and xx.
  • 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 exe^x, sin⁡x\sin x, or ln⁡x\ln x, 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 nn 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 f(x)−Tn(x)f(x) - T_n(x) that depends only on the derivatives of ff 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 ff has derivatives of all orders at aa. The Taylor polynomial of degree nn at aa is

Tn(x)=∑k=0nf(k)(a)k!(x−a)k,T_n(x) = \sum_{k=0}^{n} \frac{f^{(k)}(a)}{k!}(x-a)^k,

and the Taylor series is the series ∑k=0∞f(k)(a)k!(x−a)k\sum_{k=0}^\infty \frac{f^{(k)}(a)}{k!}(x-a)^k whose partial sums are these polynomials. It is defined by its coefficients alone; whether it converges at a given xx is a separate question. At a=0a=0 it is called the Maclaurin series. The coefficients are forced by the requirement that TnT_n match ff and its first nn derivatives at aa, which is the same formula ck=f(k)(a)/k!c_k = f^{(k)}(a)/k! that term-by-term differentiation gave in the previous lesson. The error is Rn(x)=f(x)−Tn(x)R_n(x) = f(x) - T_n(x).

Taylor's theorem and the Lagrange remainder

Hypotheses. f(n)f^{(n)} is continuous on the closed interval II between aa and xx, and f(n+1)f^{(n+1)} exists on the open interval inside it. Conclusion. There is a number ξ\xi strictly between aa and xx such that

Rn(x)=f(n+1)(ξ)(n+1)!(x−a)n+1.R_n(x) = \frac{f^{(n+1)}(\xi)}{(n+1)!}(x-a)^{n+1}.

The point ξ\xi is not known, so the theorem is used through a bound. If ∣f(n+1)(t)∣≤M\lvert f^{(n+1)}(t)\rvert \le M for all tt in II, then

∣Rn(x)∣≤M ∣x−a∣n+1(n+1)!.\lvert R_n(x)\rvert \le \frac{M\,\lvert x-a\rvert^{n+1}}{(n+1)!}.

The value MM must bound the derivative on the whole interval between aa and xx, not just at aa. The case n=0n=0 is the Mean Value Theorem, f(x)−f(a)=f′(ξ)(x−a)f(x)-f(a) = f'(\xi)(x-a) (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 f(x)f(x) exactly when Rn(x)→0R_n(x) \to 0. Both parts can fail separately.

For exe^x every derivative is exe^x, so M=e∣x∣M = e^{\lvert x\rvert} works for any xx and ∣Rn∣≤e∣x∣∣x∣n+1/(n+1)!→0\lvert R_n\rvert \le e^{\lvert x\rvert}\lvert x\rvert^{n+1}/(n+1)! \to 0, because factorials outgrow exponentials. The same argument with M=1M=1 works for sin⁡\sin and cos⁡\cos. These three series therefore equal their functions on all of R\mathbb R.

Convergence of the series alone does not settle it. The function f(x)=e−1/x2f(x) = e^{-1/x^2} for x≠0x\neq0, with f(0)=0f(0)=0, has f(k)(0)=0f^{(k)}(0) = 0 for every kk (Example 4). Its Maclaurin series is identically 00, so it converges everywhere, and it equals ff only at x=0x=0. The function is infinitely differentiable but not equal to its Taylor series.

The series can also stop short of the function's domain. ln⁡(1+x)\ln(1+x) is defined for all x>−1x>-1, but its Maclaurin series has radius 11 and diverges at x=2x = 2.

Standard Maclaurin series

  • exe^x: ∑xn/n!\sum x^n/n!, converging to the function for all real xx.
  • sin⁡x\sin x: ∑(−1)nx2n+1/(2n+1)!\sum (-1)^n x^{2n+1}/(2n+1)!, converging to the function for all real xx.
  • cos⁡x\cos x: ∑(−1)nx2n/(2n)!\sum (-1)^n x^{2n}/(2n)!, converging to the function for all real xx.
  • 11−x\frac{1}{1-x}: ∑xn\sum x^n, converging to the function for −1<x<1-1 < x < 1.
  • ln⁡(1+x)\ln(1+x): ∑n≥1(−1)n+1xn/n\sum_{n\ge1} (-1)^{n+1} x^n/n, converging to the function for −1<x≤1-1 < x \le 1.
  • arctan⁡x\arctan x: ∑(−1)nx2n+1/(2n+1)\sum (-1)^n x^{2n+1}/(2n+1), converging to the function for −1≤x≤1-1 \le x \le 1.

The last three are the ones where endpoints matter. For ln⁡(1+x)\ln(1+x) the endpoint x=1x=1 is included and x=−1x=-1 is excluded (it gives −∑1/n-\sum 1/n).

Three ways to bound an error

  1. Lagrange bound, as above, for any smooth function.
  2. Alternating series bound, ∣RN∣≤bN+1\lvert R_N\rvert \le b_{N+1}, when the terms alternate and decrease to 00 (see convergence-tests). It needs no derivatives.
  3. Geometric tail bound, when terms are dominated by a ratio r<1r<1: the sum of the terms from tKt_K on is at most tK/(1−r)t_K/(1-r) if each term is at most rr times the previous one.

How many terms are needed

Fix the tolerance ε\varepsilon, the point xx, and a bound MM. The smallest nn with M∣x−a∣n+1/(n+1)!≤εM\lvert x-a\rvert^{n+1}/(n+1)! \le \varepsilon guarantees the accuracy. It is a guarantee, not a prediction: the true error is often several times smaller.

Worked Examples

Example 1: ee to six decimals, and a wrong MM

Approximate e=e1e = e^1 with the Maclaurin polynomial at a=0a=0, x=1x=1, tolerance 10−610^{-6}. On [0,1][0,1] every derivative of exe^x is at most e<3e<3, so take M=3M=3. Then ∣Rn∣≤3/(n+1)!\lvert R_n\rvert \le 3/(n+1)!. Because 3/9!=8.3×10−63/9! = 8.3\times10^{-6} and 3/10!=8.27×10−73/10! = 8.27\times10^{-7}, the first nn that works is n=9n=9, that is, T9(1)=∑k=091/k!T_9(1) = \sum_{k=0}^9 1/k!. A script compares the bound with the actual error e−Tn(1)e - T_n(1):

text
n 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 nn (a script confirms it for n=0,…,30n=0,\ldots,30 in 80-digit arithmetic), and here it is about 2.72.7 times too large. Here n=8n=8 really does miss the target: its actual error is 3.06×10−63.06\times10^{-6}. If M=1M=1 had been used, taking f(10)(0)f^{(10)}(0) instead of the maximum on [0,1][0,1], the bound would read 1/10!=2.76×10−71/10! = 2.76\times10^{-7} at n=9n=9, smaller than the actual error 3.03×10−73.03\times10^{-7}. A wrong MM is not just loose; it is false.

Example 2: sin⁡1\sin 1 to ten decimals

With M=1M=1 (any derivative of sin⁡\sin is ±sin⁡\pm\sin or ±cos⁡\pm\cos), ∣Rn(1)∣≤1/(n+1)!\lvert R_n(1)\rvert \le 1/(n+1)!. We need 1/(n+1)!<10−101/(n+1)! < 10^{-10}, which first happens at n+1=14n+1 = 14 (13!=6.2×10913! = 6.2\times10^9 is too small, 14!=8.7×101014! = 8.7\times10^{10} is enough). Hence n=13n=13, and T13(1)=0.8414709848087…T_{13}(1) = 0.8414709848087\ldots against sin⁡1=0.8414709848079…\sin 1 = 0.8414709848079\ldots, with actual error 7.6×10−137.6\times10^{-13} and bound 1.1×10−111.1\times10^{-11}. The bound is loose by a factor of 1515 because the Taylor polynomial of sin⁡\sin has no even terms, so T13=T14T_{13}=T_{14} and the bound with n=14n=14 gives 1/15!=7.6×10−131/15! = 7.6\times10^{-13}, the actual error to two digits. The bound is only as sharp as the nn it is applied with.

Example 3: the same number, far fewer terms (ln⁡2\ln 2 and sin⁡3\sin 3)

The series ln⁡(1+x)=∑(−1)n+1xn/n\ln(1+x) = \sum (-1)^{n+1}x^n/n at x=1x=1 gives ln⁡2\ln 2, and the alternating bound is ∣RN∣≤1/(N+1)\lvert R_N\rvert \le 1/(N+1). Reaching 10−1010^{-10} would take about 101010^{10} terms. (The Lagrange bound agrees: on [0,1][0,1] the maximum of ∣f(N+1)∣\lvert f^{(N+1)}\rvert is N!N!, giving 1/(N+1)1/(N+1).) A smarter route subtracts the series for ln⁡(1−x)\ln(1-x) to get

ln⁡1+y1−y=2∑k≥0y2k+12k+1,∣y∣<1.\ln\frac{1+y}{1-y} = 2\sum_{k\ge0}\frac{y^{2k+1}}{2k+1}, \qquad \lvert y\rvert<1.

Taking y=13y=\tfrac13 gives ln⁡2\ln 2. Each term is smaller than the previous by at least a factor of y2=19y^2 = \tfrac19, so the tail after KK terms is at most 2y2K+1/((2K+1)(1−y2))2y^{2K+1}/\big((2K+1)(1-y^2)\big). This is below 10−1010^{-10} at K=10K=10 (bound 1.0×10−111.0\times10^{-11}, actual error 1.0×10−111.0\times10^{-11}), against 101010^{10} 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 sin⁡3\sin 3 to within 10−1010^{-10} from the Maclaurin series, the bound 3n+1/(n+1)!3^{n+1}/(n+1)! first drops below 10−1010^{-10} at n=21n=21 (bound 2.8×10−112.8\times10^{-11}, actual error 3.6×10−123.6\times10^{-12}). Expanding at a=πa=\pi instead, where x−a=3−π=−0.1416x-a = 3-\pi = -0.1416 is small, the bound ∣x−a∣n+1/(n+1)!\lvert x-a\rvert^{n+1}/(n+1)! is below 10−1010^{-10} already at n=7n=7 (bound 4.0×10−124.0\times10^{-12}, actual error 6.3×10−146.3\times10^{-14}). The polynomial is T7(3)=−[h−h3/3!+h5/5!−h7/7!]T_7(3) = -\big[h - h^3/3! + h^5/5! - h^7/7!\big] with h=3−πh = 3-\pi, because sin⁡x=−sin⁡(x−π)\sin x = -\sin(x-\pi). Four nonzero terms replace eleven.

Example 4: a function not equal to its Taylor series

Let f(x)=e−1/x2f(x) = e^{-1/x^2} for x≠0x\ne0 and f(0)=0f(0)=0. For every kk, f(k)(x)f^{(k)}(x) is a sum of terms of the form p(1/x) e−1/x2p(1/x)\,e^{-1/x^2} with pp a polynomial, and e−1/x2e^{-1/x^2} goes to 00 faster than any power of xx, so f(k)(0)=0f^{(k)}(0)=0 (a script verifies this by limits for k=1,…,5k=1,\ldots,5). The Maclaurin series is 0+0x+0x2+⋯0+0x+0x^2+\cdots. But f(0.5)=e−4=0.0183f(0.5) = e^{-4} = 0.0183 and f(1)=0.3679f(1) = 0.3679. The series converges at every xx, to the wrong value. In Taylor's theorem terms: Rn(x)=f(x)R_n(x) = f(x) for all nn, and it never tends to 00.

Example 5: where the bound is useless

For ln⁡(1+x)\ln(1+x) at x=2x=2 (outside the radius), ∣f(n+1)∣=n!/(1+t)n+1≤n!\lvert f^{(n+1)}\rvert = n!/(1+t)^{n+1} \le n! on [0,2][0,2], giving ∣Rn(2)∣≤2n+1/(n+1)\lvert R_n(2)\rvert \le 2^{n+1}/(n+1), which grows without bound, and the partial sums confirm it: T3(2)=2.67T_3(2) = 2.67, T5(2)=5.07T_5(2) = 5.07, T10(2)=−64.8T_{10}(2) = -64.8, T20(2)=−34 360T_{20}(2) = -34\,360, while ln⁡3=1.0986\ln 3 = 1.0986. The bound is not merely weak; the series genuinely diverges, because the terms 2n/n2^n/n do not tend to 00. At x=12x=\tfrac12, by contrast, the same bound 0.5n+1/(n+1)0.5^{n+1}/(n+1) is 9.5×10−79.5\times10^{-7} at n=15n=15, with actual error 6.5×10−76.5\times10^{-7}.

Example 6: Taylor is not what libraries use ("book vs today")

A degree-7 Taylor polynomial for sin⁡\sin on [−π/2,π/2][-\pi/2,\pi/2] has maximum error 1.57×10−41.57\times10^{-4}, at the ends, matching the Lagrange bound (π/2)9/9!=1.60×10−4(\pi/2)^9/9! = 1.60\times10^{-4} (using n=8n=8 since T7=T8T_7=T_8). A polynomial interpolating sin⁡\sin at 9 Chebyshev nodes (degree 8, which reduces to degree 7 for an odd function) has maximum error 5.95×10−75.95\times10^{-7} on the same interval. The best possible degree-7 polynomial (minimax) has maximum error about 5.9×10−75.9\times10^{-7}, 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 ff always equals ff." Example 4 is infinitely differentiable and has a Taylor series that equals it only at one point. Equality needs Rn→0R_n \to 0.
  • "If the function is defined at xx, the Taylor series converges there." ln⁡(1+x)\ln(1+x) at x=2x=2 is the counterexample (Example 5); the radius of the series is the limit.
  • "Take MM from the derivative at the center." MM must bound the derivative on the whole interval between aa and xx. 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 Tn(x)=∑k≤nf(k)(a)(x−a)k/k!T_n(x)=\sum_{k\le n} f^{(k)}(a)(x-a)^k/k! matches ff and its first nn derivatives at aa, and the Taylor series is the series whose partial sums they are. Taylor's theorem, valid when f(n)f^{(n)} is continuous on the interval and f(n+1)f^{(n+1)} exists inside it, gives the remainder f(n+1)(ξ)(x−a)n+1/(n+1)!f^{(n+1)}(\xi)(x-a)^{n+1}/(n+1)! and the bound M∣x−a∣n+1/(n+1)!M\lvert x-a\rvert^{n+1}/(n+1)!, with MM over the whole interval. Solving that bound for nn answers "how many terms", and a script can confirm the bound against the true error. The series equals the function only where Rn→0R_n\to0: this holds for exe^x, sin⁡x\sin x and cos⁡x\cos x everywhere, for ln⁡(1+x)\ln(1+x) on (−1,1](-1,1], and fails for the flat function e−1/x2e^{-1/x^2} at every x≠0x \ne 0. Choosing the expansion or the center well, as for ln⁡2\ln 2 with y=13y=\tfrac13 and sin⁡3\sin 3 at a=πa=\pi, can matter far more than adding terms.

Documentation Links