What degree does a Taylor polynomial need?
A polynomial needs only additions and multiplications. What degree does it take for a polynomial to stay within 0.005 of ex for every x from −1 to 1, and is there always a degree that does the job?
The polynomial to use is the Taylor polynomial, built from the value and the derivatives of the function at one center point. Stage 1 gives you four challenges: you choose the degree and the center, and the page says at once whether the polynomial stays within the tolerance on the whole interval.
Before you start · 3 quick checks on the tangent line, higher derivatives and factorials, about 3 min
Notation. \(f^{(k)}\) is the \(k\)-th derivative of \(f\), with \(f^{(0)} = f\), \(f^{(1)} = f'\) and \(f^{(2)} = f''\). For a whole number \(k \ge 1\), \({k!} = 1 \cdot 2 \cdots k\), and \(0! = 1\).
Taylor polynomial. Let \(f\) be \(n\) times differentiable at the point \(a\), the center. The Taylor polynomial of degree \(n\) of \(f\) at \(a\) is
\[\begin{aligned} T_n(x) &= \sum_{k=0}^{n} \frac{f^{(k)}(a)}{k!}(x - a)^k \\ &= f(a) + f'(a)(x - a) \\ &\quad + \frac{f''(a)}{2!}(x - a)^2 + \cdots \\ &\quad + \frac{f^{(n)}(a)}{n!}(x - a)^n. \end{aligned}\]For \(n = 1\) it is the tangent line \(f(a) + f'(a)(x - a)\) from What a derivative measures when you zoom in. It has the same value and the same first \(n\) derivatives at \(a\) as \(f\); stage 3 proves that these coefficients are the only ones that do this.
Fitting within a tolerance. For a number \(\varepsilon \gt 0\) and an interval \([L, R]\), say that \(T_n\) fits within \(\varepsilon\) on \([L, R]\) when \(|f(x) - T_n(x)| \le \varepsilon\) for every \(x\) with \(L \le x \le R\): over the whole interval, the graph of \(T_n\) stays inside the band of half-width \(\varepsilon\) around the graph of \(f\).
Fine print: degree and names
\(T_n\) has degree at most \(n\); its degree is lower when \(f^{(n)}(a) = 0\). With the center \(a = 0\) the polynomial is also called a Maclaurin polynomial. The infinite sum \(\sum_{k \ge 0} \tfrac{f^{(k)}(a)}{k!}(x - a)^k\), for a function with derivatives of every order, is the Taylor series of \(f\) at \(a\); \(T_n\) is its partial sum up to \(k = n\).
Choose the degree and the center until it fits
Four challenges. In each, the goal is the smallest degree \(n\) for which \(T_n\) stays within \(\varepsilon\) of \(f\) on the whole target interval, using any of the allowed centers. Set \(n\) with the slider and the center \(a\) with the buttons; the page draws \(f\), \(T_n\) and the \(\varepsilon\) band, and says at once whether \(T_n\) fits. If you decide that no degree can fit, press No degree works.
How the page decides “fits”
The page computes \(|f(x) - T_n(x)|\) at 4,001 equally spaced points of the target interval. Between two neighboring points the error can rise above the larger of its two values by at most half the spacing times a bound on the slope of \(f - T_n\). That slope bound is \(|f'(x) - T_n'(x)| \le \tfrac{M}{n!}|x - a|^n\), where \(M\) is the largest value of \(|f^{(n+1)}|\) between \(a\) and \(x\). For \(n \ge 1\) it is the Lagrange remainder of stage 2 applied to \(f'\), since \(T_n'\) is the Taylor polynomial of degree \(n - 1\) of \(f'\). For \(n = 0\), \(T_0\) is a constant, so \(T_0' = 0\) and \(|f'(x) - T_0'(x)| = |f'(x)| \le M\), the same bound.
The verdict is “fits” only if the largest computed value plus that allowance is at most \(\varepsilon\), and “does not fit” only if some computed point is already above \(\varepsilon\). For every choice on this page one of the two happens, so the verdict is never wrong between grid points. The largest error shown is the largest computed value, rounded.
How fast the error shrinks near the center
Here \(f(x) = e^x\), the center is 0, and \(h \gt 0\) is the distance from the center, so the error of \(T_n\) at \(h\) is \(e^h - T_n(h)\).
The remainder formula, the table and its goals open after you answer the prediction.
Let \(n \ge 0\) be a whole number, and let \(f\) be \(n + 1\) times differentiable on an open interval that contains \(a\) and \(x\). Then there is a number \(\xi\) between \(a\) and \(x\) (strictly between when \(x \ne a\)) with
\[\begin{aligned} &f(x) - T_n(x) \\ &= \frac{f^{(n+1)}(\xi)}{(n+1)!}(x - a)^{n+1}. \end{aligned}\]So if \(|f^{(n+1)}(t)| \le M\) for every \(t\) between \(a\) and \(x\), then \(|f(x) - T_n(x)| \le \tfrac{M}{(n+1)!}|x - a|^{n+1}\).
For \(e^x\) every derivative is \(e^t\). With \(a = 0\) and \(x = h \gt 0\), the error is \(e^h - T_n(h) = \tfrac{e^{\xi}}{(n+1)!}h^{n+1}\) for some \(\xi\) with \(0 \lt \xi \lt h\), and \(1 \lt e^{\xi} \lt e^h\). The table uses the bound \(\tfrac{e^h}{(n+1)!}h^{n+1}\).
Goals
| h | Error eʰ − Tₙ(h) | Lagrange bound | Error at 2h ÷ error at h |
|---|
Why Taylor coefficients contain factorials
Let \(n \ge 0\) be a whole number, \(a\) a real number, and
\[\begin{aligned} p(x) &= \sum_{j=0}^{n} c_j\,(x - a)^j \end{aligned}\]a polynomial of degree at most \(n\) written in powers of \(x - a\), with real coefficients \(c_0, \ldots, c_n\). Then \(p^{(k)}(a) = k!\,c_k\) for every \(k = 0, 1, \ldots, n\). So if \(f\) is \(n\) times differentiable at \(a\) and \(p^{(k)}(a) = f^{(k)}(a)\) for \(k = 0, \ldots, n\), then \(c_k = \tfrac{f^{(k)}(a)}{k!}\) for each \(k\), and \(p = T_n\).
Fix \(k\) with \(0 \le k \le n\), then choose each step of the proof.
Letting \(n \to \infty\) in \(T_n\) at the center 0 gives these series:
\[\begin{aligned} e^x &= 1 + x + \frac{x^2}{2!} + \frac{x^3}{3!} + \cdots, \\ \sin x &= x - \frac{x^3}{3!} + \frac{x^5}{5!} - \cdots, \\ \cos x &= 1 - \frac{x^2}{2!} + \frac{x^4}{4!} - \cdots, \end{aligned}\]each for every real \(x\), and
\[\begin{aligned} \ln(1 + x) &= x - \frac{x^2}{2} + \frac{x^3}{3} - \cdots \end{aligned}\]for \(-1 \lt x \le 1\) only; for every other \(x\) this series diverges.
Why. Every derivative of \(e^x\) is \(e^x\) (shown in What happens to (1 + 1/n)n as n grows?), and every derivative of \(\sin\) or \(\cos\) is \(\pm\sin\) or \(\pm\cos\). So between 0 and \(x\) they are at most \(e^{|x|}\) or 1 in size, and by the Lagrange remainder \(|f(x) - T_n(x)| \le M\tfrac{|x|^{n+1}}{(n+1)!}\), which tends to 0 as \(n \to \infty\) for each fixed \(x\). For \(\ln(1 + x)\) with \(x \gt -1\), integrate \(\tfrac{1}{1 + t} = 1 - t + \cdots + (-t)^{n-1} + \tfrac{(-t)^n}{1 + t}\) from 0 to \(x\): the error is \(\ln(1 + x) - T_n(x) = (-1)^n \int_0^x \tfrac{t^n}{1 + t}\,dt\). For \(0 \le x \le 1\) its size is at most \(\int_0^x t^n\,dt = \tfrac{x^{n+1}}{n+1}\), and for \(-1 \lt x \lt 0\) at most \(\tfrac{|x|^{n+1}}{(n+1)(1 + x)}\); both tend to 0. For \(|x| \gt 1\) the terms \(\tfrac{x^k}{k}\) do not tend to 0, and at \(x = -1\) the series is \(-(1 + \tfrac{1}{2} + \tfrac{1}{3} + \cdots)\), which diverges.
Problems
Each problem has hints and a full solution. Exact answers can be typed as a decimal or a fraction.
Related: the chain rule gives the derivatives of \(e^{cx}\) used above, and What happens to (1 + 1/n)n as n grows? shows why \(e^x\) is its own derivative.
Further reading
- J. Stewart, Calculus: Early Transcendentals, 8th ed. (Cengage, 2016), sections 11.10, “Taylor and Maclaurin Series,” and 11.11, “Applications of Taylor Polynomials.”
- M. Spivak, Calculus, 4th ed. (Publish or Perish, 2008), chapter 20, “Approximation by Polynomial Functions.”
- T. M. Apostol, Calculus, Vol. 1, 2nd ed. (Wiley, 1967), chapter 7, “Polynomial Approximations to Functions.”
- J. C. Hull, Options, Futures, and Other Derivatives, 10th ed. (Pearson, 2018), chapter 4, “Interest Rates,” on duration and convexity.