Skip to main content
Mathematics LibreTexts

9.5: Taylor's Series

  • Page ID
    139484
  • \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)

    \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)

    \( \newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\)

    ( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\)

    \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\)

    \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\)

    \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\)

    \( \newcommand{\Span}{\mathrm{span}}\)

    \( \newcommand{\id}{\mathrm{id}}\)

    \( \newcommand{\Span}{\mathrm{span}}\)

    \( \newcommand{\kernel}{\mathrm{null}\,}\)

    \( \newcommand{\range}{\mathrm{range}\,}\)

    \( \newcommand{\RealPart}{\mathrm{Re}}\)

    \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\)

    \( \newcommand{\Argument}{\mathrm{Arg}}\)

    \( \newcommand{\norm}[1]{\| #1 \|}\)

    \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\)

    \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\AA}{\unicode[.8,0]{x212B}}\)

    \( \newcommand{\vectorA}[1]{\vec{#1}}      % arrow\)

    \( \newcommand{\vectorAt}[1]{\vec{\text{#1}}}      % arrow\)

    \( \newcommand{\vectorB}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)

    \( \newcommand{\vectorC}[1]{\textbf{#1}} \)

    \( \newcommand{\vectorD}[1]{\overrightarrow{#1}} \)

    \( \newcommand{\vectorDt}[1]{\overrightarrow{\text{#1}}} \)

    \( \newcommand{\vectE}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash{\mathbf {#1}}}} \)

    \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)

    \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)

    In the previous section a few functions, e.g. \(f(x) = \frac{1}{1-x}\), turned out to be the sum of a power series. This section will discuss a general method for representing a function as a power series, called a Taylor’s series.11 Suppose that a function \(f(x)\) can be written as

    \[f(x) ~=~ \sum_{n=0}^{\infty}\,a_n\,(x-c)^n \nonumber \]

    either for all \(x\) or for \(\abs{x-c} < R\), for some \(R>0\). Then \(f(c) = a_0\), and differentiating term by term yields

    \[\begin{aligned} {4} f'(x) ~&=~ \sum_{n=1}^{\infty}\,n\,a_n\,(x-c)^{n-1} &&\Rightarrow \quad &f'(c) ~&=~ 1\,\cdot\,a_1\

    \[2pt] f''(x) ~&=~ \sum_{n=2}^{\infty}\,n\,(n-1)\,a_n\,(x-c)^{n-2} &&\Rightarrow \quad &f''(c) ~&=~ 2\,\cdot\,1\,\cdot\,a_2\

    \[2pt] f'''(x) ~&=~ \sum_{n=3}^{\infty}\,n\,(n-1)\,(n-2)\,a_n\,(x-c)^{n-3} &&\Rightarrow \quad &f'''(c) ~&=~ 3\,\cdot\,2\,\cdot\,1\,\cdot\,a_3\\ &\cdots & {} & {} & {} &\cdots\\ f^{(k)}(x) ~&=~ \sum_{n=k}^{\infty}\,n\,(n-1)\,(n-2)\,\cdots\,(n-k+1)\,a_n\,(x-c)^{n-k} \quad &&\Rightarrow \quad &f^{(k)}(c) ~&=~ k !\;a_k\end{aligned} \nonumber \]

    so that in general (since \(f^{(0)}(x) = f(x)\) and \(0 ! = 1\)):

    \[\label{eqn:taylorcoeff} a_n ~=~ \frac{f^{(n)}(c)}{n !} \quad\text{for $~n \ge 0$} \]

    These \(\seq{a_n}\) are the Taylor’s series coefficients of \(f(x)\) at \(x=c\). The full power series representation of \(f(x)\) can now be stated:

    Example \(\PageIndex{1}\): taylorexp

    Add text here.

    Solution

    Find the Taylor’s series for \(f(x)=e^x\) about \(x=0\).

    \[\begin{aligned} e^x ~&=~ \bigsum{n=0}{\infty}~ \frac{f^{(n)}(0)}{n !}\,x^n ~=~ \bigsum{n=0}{\infty}~ \frac{x^n}{n !}\\ &=~ 1 ~+~ x ~+~ \frac{x^2}{2 !} ~+~ \frac{x^3}{3 !} ~+~ \frac{x^4}{4 !} ~+~ \frac{x^5}{5 !} ~+~ \cdots\end{aligned} \nonumber \]

    For what \(x\) is this Taylor’s series valid? Recall that Example

    Example \(\PageIndex{1}\): expseries

    Add text here.

    Solution

    showed the interval of convergence is all of \(\Reals\). Thus the above Taylor’s series holds for all \(x\).

    Before continuing, you might be wondering why you should even bother with finding the Taylor’s series—after all, in the above example why replace a simple function like \(e^x\) by a far more complicated expression? One reason is that it often helps simplify some computations, especially in integrals. The idea is to use only a few terms in the series, i.e. a polynomial, as an approximation, since polynomials are generally easier to work with. Perhaps surprisingly, in many practical applications no more than two terms are needed, and often only one.

    For example, using only the first two terms of the Taylor’s series for \(e^x\) in Example

    Example \(\PageIndex{1}\): taylorexp

    Add text here.

    Solution

    , \(e^x \approx 1 + x\) is a good approximation when \(x\) is close to 0 (i.e. \(\abs{x} \ll 1\)). Using more terms does not necessarily help—for \(\abs{x} \ll 1\) and \(n>1\), \(x^n\) will be effectively 0. So the added complexity would not make the approximation significantly better.

    Example \(\PageIndex{1}\): approxe

    Add text here.

    Solution

    The energy density \(E\) of electromagnetic radiation at wavelength \(\lambda\) from a black-body at temperature \(T\) degrees Kelvin is given by Planck’s Law of black-body radiation,

    \[E(\lambda) ~=~ \frac{8\pi h c}{\lambda^5 (e^{hc/\lambda kT} - 1)} \nonumber \]

    where \(h\) is Planck’s constant, \(c\) is the speed of light, and \(k\) is Boltzmann’s constant. Show that for \(\lambda \gg 1\):

    \[E(\lambda) ~\approx~ \frac{8\pi kT}{\lambda^4} \nonumber \]

    Solution: Since \(e^x ~\approx~ 1 + x\;\) for \(\abs{x} \ll 1\) by the Taylor series for \(e^x\), let \(x = hc/\lambda kT\). Then \(x \ll 1\) and so

    \[E(\lambda) ~=~ \frac{8\pi h c}{\lambda^5 (e^{hc/\lambda kT} - 1)} ~\approx~ \frac{8\pi h c}{\lambda^5 \left(\left(1 + \frac{hc}{\lambda kT}\right) - 1\right)} ~\approx~ \frac{8\pi h c}{\lambda^5 \frac{hc}{\lambda kT}} ~\approx~ \frac{8\pi kT}{\lambda^4} \nonumber \]

    Example \(\PageIndex{1}\): taylorsin

    Add text here.

    Solution

    Find the Taylor’s series for \(f(x)=\sin\,x\) about \(x=0\).

    Solution: The derivatives of \(f(x)=\sin\,x\) repeat every four derivatives:

    \[f(x) ~=~ \sin\,x \quad,\quad f'(x) ~=~ \cos\,x \quad,\quad f''(x) ~=~ -\sin\,x \quad,\quad f'''(x) ~=~ -\cos\,x \quad,\quad f^{(4)}(x) ~=~ \sin\,x \nonumber \]

    So at \(x=0\):

    \[f(0) ~=~ 0 \quad,\quad f'(x) ~=~ 1 \quad,\quad f''(x) ~=~ 0 \quad,\quad f'''(x) ~=~ -1 \quad,\quad f^{(4)}(x) ~=~ 0 \nonumber \]

    So for \(n\ge 0\),

    \[f^{(n)}(0) ~=~ \begin{cases} ~0 & \text{if $~n$ is even,}\\ ~1 & \text{if $~n=1,5,9,\ldots$,}\\~-1 & \text{if $~n=3,7,11,\ldots$.}\end{cases} \nonumber \]

    Thus, by Taylor’s formula with \(c=0\)

    \[\begin{aligned} \sin\,x ~&=~ \bigsum{n=0}{\infty}~ \frac{f^{(n)}(0)}{n !}\,x^n\

    \[4pt] &=~ x ~-~ \frac{x^3}{3 !} ~+~ \frac{x^5}{5 !} ~-~ \frac{x^7}{7 !} ~+~ \frac{x^9}{9 !} ~-~ \cdots\

    \[4pt] &=~ \bigsum{n=0}{\infty}~ (-1)^{n}\,\frac{x^{2n+1}}{(2n+1) !}\end{aligned} \nonumber \]

    By the Ratio Test this series converges for all \(x\), since for any fixed \(x\),

    \[r(x) ~=~ \lim_{n \to \infty} \;\left|\dfrac{(-1)^{n+1}\,\dfrac{x^{2n+3}}{(2n+3) !}} {(-1)^{n}\,\dfrac{x^{2n+1}}{(2n+1) !}}\right| ~=~ x^2 \;\cdot\; \lim_{n \to \infty} \;\Biggl|\frac{1}{(2n+3)\,(2n+2)}\Biggr| ~=~ 0 ~<~ 1 ~. \nonumber \]

    Example \(\PageIndex{1}\): taylorcos

    Add text here.

    Solution

    Find the Taylor’s series for \(f(x)=\cos\,x\) about \(x=0\).

    Solution: The Taylor’s series can be found using the same procedure as in Example

    Example \(\PageIndex{1}\): taylorsin

    Add text here.

    Solution

    , but it is simpler to just differentiate the Taylor’s series for \(\sin\,x\) term by term for all \(x\):

    \[\begin{aligned} \cos\,x ~&=~ \ddx\,(\sin\,x) ~=~ \ddx\,\left(x ~-~ \frac{x^3}{3 !} ~+~ \frac{x^5}{5 !} ~-~ \frac{x^7}{7 !} ~+~ \frac{x^9}{9 !} ~-~ \cdots\right)\

    \[4pt] &=~ 1 ~-~ \frac{x^2}{2 !} ~+~ \frac{x^4}{4 !} ~-~ \frac{x^6}{6 !} ~+~ \frac{x^8}{8 !} ~-~ \cdots\

    \[4pt] &=~ \bigsum{n=0}{\infty}~ (-1)^{n}\,\frac{x^{2n}}{(2n) !}\end{aligned} \nonumber \]

    Since the Taylor’s series for \(\sin\,x\) converges for all \(x\) then so does its derivative. Thus the Taylor’s series for \(\cos\,x\) converges for all \(x\).
    Notice that the Taylor’s series for \(\cos\,x\) has only even powers of \(x\), while the series for \(\sin\,x\) has only odd powers of \(x\). This makes sense since \(\cos\,x\) and \(\sin\,x\) are even and odd functions, respectively.

    Example \(\PageIndex{1}\): taylorlog

    Add text here.

    Solution

    The function \(\ln\,x\) is not defined at \(x=0\) nd hence has no Taylor’s series about \(x=0\). Instead, find the Taylor’s series for \(f(x)=\ln\,(1+x)\) about \(x=0\).

    Solution: Take successive derivatives:

    \[f(x) ~=~ \ln\,(1+x) \quad,\quad f'(x) ~=~ \frac{1}{1+x} \quad,\quad f''(x) ~=~ -\frac{1}{(1+x)^2} \quad,\quad f'''(x) ~=~ \frac{1 \,\cdot\, 2}{(1+x)^3} \quad,\quad f^{(4)}(x) ~=~ -\frac{1 \,\cdot\, 2 \,\cdot\, 3}{(1+x)^4} \nonumber \]

    So \(f(0)=0\) and for \(n\ge 1\):

    \[f^{(n)}(x) ~=~ (-1)^{n-1}\,\frac{(n-1) !}{(1+x)^n} \quad\Rightarrow\quad f^{(n)}(0) ~=~ (-1)^{n-1}\,(n-1) ! \nonumber \]

    Thus, by Taylor’s formula,

    \[\begin{aligned} \ln\,(1+x) ~&=~ \bigsum{n=0}{\infty}~ \frac{f^{(n)}(0)}{n !}\,x^n ~=~ \bigsum{n=1}{\infty}~ (-1)^{n-1}\,\frac{(n-1) !\,x^{n}}{n !}\

    \[4pt] &=~ \bigsum{n=1}{\infty}~ (-1)^{n-1}\,\frac{x^{n}}{n}\

    \[4pt] &=~ x ~-~ \frac{x^2}{2} ~+~ \frac{x^3}{3} ~-~ \frac{x^4}{4} ~+~ \frac{x^5}{5} ~-~ \cdots\end{aligned} \nonumber \]

    Use the Ratio Test to find the interval of convergence:

    \[r(x) ~=~ \lim_{n \to \infty} \;\left|\dfrac{(-1)^{n}\,\dfrac{x^{n+1}}{n+1}} {(-1)^{n-1}\,\dfrac{x^{n}}{n}}\right| ~=~ \abs{x} \;\cdot\; \lim_{n \to \infty} \;\Biggl|\frac{n}{n+1}\Biggr| ~=~ \abs{x} \,\cdot\, 1 ~=~ \abs{x} \nonumber \]

    So the series converges when \(\abs{x} < 1\). Check the cases \(r(x)=\abs{x}=1\) individually. For \(x=1\) the series is the alternating harmonic series \(\sum_{n=1} \frac{(-1)^{n-1}}{n}\), which converges. For \(x=-1\) the series is \(-\sum_{n=1} \frac{1}{n}\), the negative of the harmonic series, which diverges. Thus, the series converges for \(-1<x\le 1\).

    Example \(\PageIndex{1}\): taylorexp2

    Add text here.

    Solution

    Find the Taylor’s series for \(f(x)=e^{x^2}\) about \(x=0\).

    Solution: The Taylor’s series can be found using the same procedure as in Example

    Example \(\PageIndex{1}\): taylorexp

    Add text here.

    Solution

    , but it is simpler to just replace each occurrence of \(x\) in the Taylor’s series for \(e^{x^2}\) by \(x^2\). In other words, make the substitution \(u=x^2\) in the Taylor’s series for \(e^u\) about \(u=0\):

    \[\begin{aligned} e^u ~&=~ \bigsum{n=0}{\infty}~ \frac{u^n}{n !}\

    \[4pt] e^{x^2} ~&=~ \bigsum{n=0}{\infty}~ \frac{(x^2)^n}{n !} ~=~ \bigsum{n=0}{\infty}~ \frac{x^{2n}}{n !}\

    \[4pt] &=~ 1 ~+~ x^2 ~+~ \frac{x^4}{2 !} ~+~ \frac{x^6}{3 !} ~+~ \frac{x^8}{4 !} ~+~ \frac{x^{10}}{5 !} ~+~ \cdots\end{aligned} \nonumber \]

    Define the \(\bm{n}\)-th degree Taylor polynomial \(P_n(x)\) for a function \(f(x)\) about \(x=c\) by

    \[\begin{aligned} P_n(x) ~&=~ \bigsum{k=0}{n}~ \frac{f^{(k)}(c)}{k !}\,(x-c)^k\\ &=~ f(c) ~+~ \frac{f'(c)}{1 !}\,(x-c) ~+~ \frac{f''(c)}{2 !}\,(x-c)^2 ~+~ \cdots ~+~ \frac{f^{(n)}(c)}{n !}\,(x-c)^n\end{aligned} \nonumber \]

    for \(x\) in the interval of convergence for the full Taylor’s series. In other words, \(P_n(x)\) is the \(n\)-th partial sum of the Taylor’s series. Since some of the coefficients could be zero, \(P_n(x)\) is a polynomial of degree at most \(n\). Thus, \(P_n(x) = O(x^n)\). For that reason \(P_n(x)\) is sometimes called the \(\bm{O(x^n)}\) approximation to \(f(x)\).

    Figure [fig:sinetaylor] shows a comparison of \(\sin\,x\) with a few of its approximations:

    \sin\,x and Taylor’s series approximations
    \(\sin\,x\) and Taylor’s series approximations

    As you can see, the Taylor polynomials of degree 7, 11 and 15 are all good approximations over the interval \(\ival{-2}{2}\), with the \(O(x^{15})\) approximation still being fairly good over \(\ival{-6}{6}\). Clearly those approximations all become poor quite quickly for \(\abs{x} > 6\); they approach \(\pm\infty\), unlike \(\sin\,x\).

    The following theorem shows how to measure the accuracy of the approximations:

    Since the number \(\theta\) is unknown in equation ([eqn:taylorrem1]), usually only an upper bound on the remainder \(R_n(x)\) can be found by that formula. For practical purposes formula ([eqn:taylorrem2]) for \(R_n(x)\) might be easier to use (via numerical integration).

    A common misconception is that hand-held calculators use Taylor’s series to compute values of functions like \(\sin\,x\), \(\cos\,x\), \(e^x\), etc. However, that is typically well their capability, especially for large values of \(x\)—far too many terms would be required. Instead, many calculators use an algorithm called CORDIC (Coordinate Rotation Digital Computer), and—perhaps surprisingly—lookup tables. CORDIC uses the computationally inexpensive operation of bit-shifting to translate large input values into a smaller range, then uses tables stored in memory for values in that range, along with interpolation for numbers between those in the tables.13

    [sec9dot5]

    For Exercises 1-9 write out the first three nonzero terms in the Taylor’s series for the given function \(f(x)\) about the given value \(c\). You may use any method you like.

    3

    \(f(x) = \sin\,x\) ; \(c = \pi/2\)

    \(f(x) = \sinh\,x\) ; \(c = 0\)

    \(f(x) = \cosh\,x\) ; \(c = 0\)

    3

    [exer:taylortan] \(f(x) = \tan\,x\) ; \(c = 0\)

    [exer:taylortanh] \(f(x) = \tanh\,x\) ; \(c = 0\)

    \(f(x) = \sec\,x\) ; \(c = 0\)

    3

    [exer:tayloratan] \(f(x) = \dfrac{1}{1 +x^2}\) ; \(c = 0\)

    \(f(x) = \dfrac{1}{1 + x^2}\) ; \(c = 1\)

    [exer:taylorsq] \(f(x) = \sqrt{1 + x^2}\) ; \(c = 0\vphantom{\dfrac{1}{x^2 ~+~ 1}}\)

    Use Example

    Example \(\PageIndex{1}\): seriesderivxn

    Add text here.

    Solution

    from Section 9.4 to write out the first three nonzero terms in the Taylor’s series for \(f(x) = \frac{1}{(1 - x)^3}\) about \(x=0\).

    Use the derivative of the Taylor’s series for \(\sqrt{1 + x^2}\) from Exercise [exer:taylorsq] to write out the first three nonzero terms in the Taylor’s series for \(f(x) ~=~ \frac{x^2}{\sqrt{1 + x^2}}\) about \(x=0\).

    For Exercises 12-15 replace the function \(f(x)\) by its Taylor’s series about \(x=0\) to evaluate the given indefinite integral \(\int f(x) \;\dx\) (up to the first three nonzero terms in the series). [[1.]]

    4

    \(\displaystyle\int \frac{\sin\,x}{x}~\dx\)

    \(\displaystyle\int \cos\,(x^2)~\dx\vphantom{\displaystyle\int \frac{\sin\,x}{x}}\)

    \(\displaystyle\int e^{-x^2}~\dx\vphantom{\displaystyle\int \frac{\sin\,x}{x}}\)

    \(\displaystyle\int \sqrt{1+x^6}~\dx\vphantom{\displaystyle\int \frac{\sin\,x}{x}}\)

    [exer:atanpi] Use \(\ddx\,(\tan^{-1} x) = \frac{1}{1+x^2}\) along with Exercise [exer:tayloratan] to find the Taylor’s series for \(f(x)=\tan^{-1} x\) about \(x=0\), along with its interval of convergence.

    Use Exercise [exer:atanpi] to show that

    \[\pi ~=~ 4\,\left(1 \;-\; \frac{1}{3} \;+\; \frac{1}{5} \;-\; \frac{1}{7} \;-\; \cdots \right) ~. \nonumber \]

    Use the first three nonzero terms in the Taylor’s series about \(x=0\) for \(e^{-x^2/2}\) to evaluate the definite integral

    \[\int_{-1}^1 ~\frac{1}{\sqrt{2\pi}} \,e^{-x^2/2}~\dx \quad . \nonumber \]

    Note: The actual value (rounded to 4 decimal places) is 0.6826.

    Recall that the surface area \(S\) of the solid obtained by revolving the curve \(y = x^2\) around the \(x\)-axis between \(x = 0\) and \(x = 2\) is given by the integral

    \[S ~=~ \int_0^2 ~2 \pi x^2 \,\sqrt{1 \;+\; 4x^2}~\dx \quad . \nonumber \]

    The exact value of the integral rounded to 3 decimal places is \(S = 53.226\). Use the first two nonzero terms in the Taylor’s series for \(\sqrt{1 + 4x^2}\) about \(x=0\) to approximate the integral. How close is this approximation to the actual value? Does the approximation become better if you use the first three nonzero terms in the Taylor’s series? Justify your answer.

    The tangential component of a space shuttle’s velocity during reentry is approximately

    \[v(t) ~=~ v_c \,\tanh\,\left( \frac{g}{v_c} t ~+~ \tanh^{-1} \left(\frac{v_0}{v_c}\right) \right) \nonumber \]

    where \(v_0\) is the velocity at time \(t=0\) and \(v_c\) is the terminal velocity. If \(\tanh^{-1} \left(\frac{v_0}{v_c}\right) = \frac{1}{2}\) then show that \(v(t) \approx gt + \frac{1}{2}v_c\).

    The velocity of a water wave of length \(L\) in water of depth \(h\) satisfies the equation \(v^2 = \frac{gL}{2\pi} \tanh \left( \frac{2\pi h}{L}\right)\). Show that \(v \approx \sqrt{gh}\).

    A disk of radius \(a\) has a charge of constant density \(\sigma\). A point \(P\) lies at a distance \(r\) directly above the disk. The electrical potential \(V\) at point \(P\) is given by \(V = 2\pi\sigma(\sqrt{r^2 + a^2} - r)\). Show that \(V \approx \frac{\pi a^2 \sigma}{r}\) for large \(r\) (i.e. \(r \gg 1\)).

    The fifth-degree Padé approximation uses rational functions to approximate \(\tanh\,x\):

    \[\tanh\,x ~\approx~ \frac{x^5 + 105x^3 + 945x}{15x^4 + 420x^2 + 945} \nonumber \]

    Compare the values of the Padé approximation and the fifth-degree Taylor’s series approximation from Exercise [exer:taylortanh], evaluated at \(x=1\). Which is better? The actual value of \(\tanh (1)\) is 0.7615941559558. How do the two approximations compare at \(x=2\)?


    This page titled 9.5: Taylor's Series is shared under a GNU General Public License 3.0 license and was authored, remixed, and/or curated by Michael Corral.

    • Was this article helpful?