# APEX Calculus

## Section9.8Taylor Series

In Section 9.6, we showed how certain functions can be represented by a power series function. In Section 9.7, we showed how we can approximate functions with polynomials, given that enough derivative information is available. In this section we combine these concepts: if a function $$f(x)$$ is infinitely differentiable, we show how to represent it with a power series function.

### Definition9.8.2.Taylor and Maclaurin Series.

Let $$f(x)$$ have derivatives of all orders at $$x=c\text{.}$$
1. The Taylor Series of $$f(x)\text{,}$$ centered at $$c$$ is
\begin{equation*} \infser[0] \frac{f^{(n)}(c)}{n!}(x-c)^n\text{.} \end{equation*}
2. Setting $$c=0$$ gives the Maclaurin Series of $$f(x)$$:
\begin{equation*} \infser[0] \frac{f^{(n)}(0)}{n!}x^n\text{.} \end{equation*}
If $$p_n(x)$$ is the $$n$$th degree Taylor polynomial for $$f(x)$$ centered at $$x=c\text{,}$$ we saw how $$f(x)$$ is approximately equal to $$p_n(x)$$ near $$x=c\text{.}$$ We also saw how increasing the degree of the polynomial generally reduced the error.
We are now considering series, where we sum an infinite set of terms. Our ultimate hope is to see the error vanish and claim a function is equal to its Taylor series.
When creating the Taylor polynomial of degree $$n$$ for a function $$f(x)$$ at $$x=c\text{,}$$ we needed to evaluate $$f\text{,}$$ and the first $$n$$ derivatives of $$f\text{,}$$ at $$x=c\text{.}$$ When creating the Taylor series of $$f\text{,}$$ it helps to find a pattern that describes the $$n$$th derivative of $$f$$ at $$x=c\text{.}$$ We demonstrate this in the next two examples.

### Example9.8.3.The Maclaurin series of $$f(x) = \cos(x)$$.

Find the Maclaurin series of $$f(x)=\cos(x)\text{.}$$
Solution 1. Video solution
Solution 2.
In Example 9.7.19 we found the $$8$$th degree Maclaurin polynomial of $$\cos(x)\text{.}$$ In doing so, we created the table shown in Table 9.8.4.
Notice how $$f^{(n)}(0)=0$$ when $$n$$ is odd, $$f^{(n)}(0)=1$$ when $$n$$ is divisible by $$4\text{,}$$ and $$f^{(n)}(0)=-1$$ when $$n$$ is even but not divisible by 4. Thus the Maclaurin series of $$\cos(x)$$ is
\begin{equation*} 1-\frac{x^2}2+\frac{x^4}{4!}-\frac{x^6}{6!}+\frac{x^8}{8!} - \cdots \end{equation*}
We can go further and write this as a summation. The coefficients alternate between positive and negative. Since we only need the terms where the power of $$x$$ is even, we write the power series in terms of $$x^{2n}\text{:}$$
\begin{equation*} \infser[0] (-1)^{n}\frac{x^{2n}}{(2n)!}\text{.} \end{equation*}
This Maclaurin series is a special type of power series. As such, we should determine its interval of convergence. Applying the Ratio Test, we have
\begin{align*} \lim_{n\to\infty}\frac{\abs{(-1)^{n+1}\dfrac{x^{2(n+1)}}{\big(2(n+1)\big)!}}}{\abs{(-1)^n\frac{x^{2n}}{(2n)!}}} \amp = \lim_{n\to\infty}\abs{\frac{x^{2n+2}}{x^{2n}}}\frac{(2n)!}{(2n+2)!}\\ \amp = \lim_{n\to\infty} \frac{\abs{x}^2}{(2n+2)(2n+1)}\text{.} \end{align*}
For any fixed $$x\text{,}$$ this limit is 0. Therefore this power series has an infinite radius of convergence, converging for all $$x\text{.}$$ It is important to note what we have, and have not, determined: we have determined the Maclaurin series for $$\cos(x)$$ along with its interval of convergence. We have not shown that $$\cos(x)$$ is equal to this power series.
Example 9.8.3 found the Taylor Series representation of $$\cos(x)\text{.}$$ We can easily find the Taylor Series representation of $$\sin(x)$$ by recognizing that $$\int \cos(x)\, dx=\sin(x)$$ and apply Theorem 9.6.9.

### Example9.8.5.The Taylor series of $$f(x)=\ln(x)$$ at $$x=1$$.

Find the Taylor series of $$f(x) = \ln(x)$$ centered at $$x=1\text{.}$$
Solution 1. Video solution
Solution 2.
Figure 9.8.6 shows the $$n$$th derivative of $$\ln(x)$$ evaluated at $$x=1$$ for $$n=0,\ldots,5\text{,}$$ along with an expression for the $$n$$th term:
\begin{equation*} f^{(n)}(1) = (-1)^{n+1}(n-1)! \text{ for $$n\geq 1$$. } \end{equation*}
Remember that this is what distinguishes Taylor series from Taylor polynomials; we are very interested in finding a pattern for the $$n$$th term, not just finding a finite set of coefficients for a polynomial.
Since $$f(1) = \ln(1) = 0\text{,}$$ we skip the first term and start the summation with $$n=1\text{,}$$ giving the Taylor series for $$\ln(x)\text{,}$$ centered at $$x=1\text{,}$$ as
\begin{equation*} \infser (-1)^{n+1}(n-1)!\frac{1}{n!}(x-1)^n = \infser (-1)^{n+1}\frac{(x-1)^n}{n}\text{.} \end{equation*}
We now determine the interval of convergence, using the Ratio Test.
\begin{align*} \lim_{n\to\infty} \frac{\abs{(-1)^{n+2}\dfrac{(x-1)^{n+1}}{n+1}}}{\abs{(-1)^{n+1}\dfrac{(x-1)^n}{n}}} \amp = \lim_{n\to\infty} \abs{\frac{(x-1)^{n+1}}{(x-1)^n}}\frac{n}{n+1}\\ \amp = \abs{x-1}\text{.} \end{align*}
By the Ratio Test, we have convergence when $$\abs{x-1} \lt 1\text{:}$$ the radius of convergence is 1, and we have convergence on $$(0,2)\text{.}$$ We now check the endpoints.
At $$x=0\text{,}$$ the series is
\begin{equation*} \sum_{n=1}^\infty (-1)^{n+1}\frac{(-1)^n}{n} = -\sum_{n=1}^\infty \frac1n\text{,} \end{equation*}
which diverges (it is the Harmonic Series times $$(-1)\text{.}$$)
At $$x=2\text{,}$$ the series is
\begin{equation*} \sum_{n=1}^\infty (-1)^{n+1}\frac{(1)^n}{n} = \sum_{n=1}^\infty (-1)^{n+1}\frac{1}{n}\text{,} \end{equation*}
the Alternating Harmonic Series, which converges.
We have found the Taylor series of $$\ln x$$ centered at $$x=1\text{,}$$ and have determined the series converges on $$(0,2]\text{.}$$ We cannot (yet) say that $$\ln x$$ is equal to this Taylor series on $$(0,2]\text{.}$$
It is important to note that Definition 9.8.2 defines a Taylor series given a function $$f(x)$$ , but makes no claim about their equality. We will find that “most of the time” they are equal, but we need to consider the conditions that allow us to conclude this.
Theorem 9.7.16 states that the error between a function $$f(x)$$ and its $$n$$th-degree Taylor polynomial $$p_n(x)$$ is $$R_n(x)\text{,}$$ where
\begin{equation*} \abs{R_n(x)} \leq \frac{\max\abs{\,f^{(n+1)}(z)}}{(n+1)!}\abs{(x-c)^{(n+1)}}\text{.} \end{equation*}
If $$R_n(x)$$ goes to 0 for each $$x$$ in an interval $$I$$ as $$n$$ approaches infinity, we conclude that the function is equal to its Taylor series expansion.
We demonstrate the use of this theorem in an example.

### Example9.8.9.Establishing equality of a function and its Taylor series.

Show that $$f(x) = \cos(x)$$ is equal to its Maclaurin series, as found in Example 9.8.3, for all $$x\text{.}$$
Solution.
Given a value $$x\text{,}$$ the magnitude of the error term $$R_n(x)$$ is bounded by
\begin{equation*} \abs{R_n(x)} \leq \frac{\max\abs{\,f^{(n+1)}(z)}}{(n+1)!}\abs{x^{n+1}}\text{.} \end{equation*}
Since all derivatives of $$\cos(x)$$ are $$\pm \sin(x)$$ or $$\pm\cos(x)\text{,}$$ whose magnitudes are bounded by $$1\text{,}$$ we can state
\begin{equation*} \abs{R_n(x)} \leq \frac{1}{(n+1)!}\abs{x^{n+1}} \end{equation*}
which implies
$$-\frac{\abs{x^{n+1}}}{(n+1)!} \leq R_n(x) \leq\frac{\abs{x^{n+1}}}{(n+1)!}\text{.}\tag{9.8.1}$$
For any $$x\text{,}$$ $$\lim\limits_{n\to\infty} \frac{x^{n+1}}{(n+1)!} = 0\text{.}$$ Applying the Squeeze Theorem to Equation (9.8.1), we conclude that $$\lim\limits_{n\to\infty} R_n(x) = 0$$ for all $$x\text{,}$$ and hence
\begin{equation*} \cos(x) = \infser[0] (-1)^{n}\frac{x^{2n}}{(2n)!} \text{ for all $$x$$ }\text{.} \end{equation*}
It is natural to assume that a function is equal to its Taylor series on the series' interval of convergence, but this is not always the case. In order to properly establish equality, one must use Theorem 9.8.7. This is a bit disappointing, as we developed beautiful techniques for determining the interval of convergence of a power series, and proving that $$R_n(x)\to 0$$ can be difficult. For instance, it is not a simple task to show that $$\ln x$$ equals its Taylor series on $$(0,2]$$ as found in Example 9.8.5; in the Exercises, the reader is only asked to show equality on $$(1,2)\text{,}$$ which is simpler.
There is good news. A function $$f(x)$$ that is equal to its Taylor series, centered at any point the domain of $$f(x)\text{,}$$ is said to be an analytic function, and most, if not all, functions that we encounter within this course are analytic functions. Generally speaking, any function that one creates with elementary functions (polynomials, exponentials, trigonometric functions, etc.) that is not piecewise defined is probably analytic. For most functions, we assume the function is equal to its Taylor series on the series' interval of convergence and only use Theorem 9.8.7 when we suspect something may not work as expected.
We develop the Taylor series for one more important function, then give a table of the Taylor series for a number of common functions.

### Example9.8.10.The Binomial Series.

Find the Maclaurin series of $$f(x) = (1+x)^k\text{,}$$ $$k\neq 0\text{.}$$
Solution 1. Video solution
Solution 2.
When $$k$$ is a positive integer, the Maclaurin series is finite. For instance, when $$k=4\text{,}$$ we have
\begin{equation*} f(x) = (1+x)^4 = 1+4x+6x^2+4x^3+x^4\text{.} \end{equation*}
The coefficients of $$x$$ when $$k$$ is a positive integer are known as the binomial coefficients, giving the series we are developing its name.
When $$k=1/2\text{,}$$ we have $$f(x) = \sqrt{1+x}\text{.}$$ Knowing a series representation of this function would give a useful way of approximating $$\sqrt{1.3}\text{,}$$ for instance.
To develop the Maclaurin series for $$f(x) = (1+x)^k$$ for any value of $$k\neq0\text{,}$$ we consider the derivatives of $$f$$ evaluated at $$x=0\text{:}$$
\begin{align*} f(x) \amp = (1+x)^k \amp f(0) \amp = 1\\ \fp(x) \amp = k(1+x)^{k-1} \amp \fp(0) \amp =k\\ \fp'(x) \amp = k(k-1)(1+x)^{k-2} \amp \fp'(0) \amp =k(k-1)\\ \fp''(x) \amp = k(k-1)(k-2)(1+x)^{k-3} \amp \fp''(0) \amp =k(k-1)(k-2)\\ \amp \vdots \amp \amp \vdots \end{align*}
For a general $$n\text{,}$$
\begin{equation*} f^{(n)}(x) = k(k-1)\cdots\bigl(k-(n-1)\bigr)(1+x)^{k-n}\text{,} \end{equation*}
giving $$f^{(n)}(0) =k(k-1)\cdots\bigl(k-(n-1)\bigr)\text{.}$$
Thus the Maclaurin series for $$f(x) = (1+x)^k$$ is
\begin{align*} (1+x)^k\amp =1+ kx + \frac{k(k-1)}{2!}x^2 + \frac{k(k-1)(k-2)}{3!}x^3 + \ldots\\ \amp \dots + \frac{k(k-1)\cdots\big(k-(n-1)\big)}{n!}(x-c)^n+\ldots \end{align*}
It is important to determine the interval of convergence of this series. With
\begin{equation*} a_n = \frac{k(k-1)\cdots\big(k-(n-1)\big)}{n!}x^n\text{,} \end{equation*}
we apply the Ratio Test:
\begin{align*} \lim_{n\to\infty}\frac{\abs{a_{n+1}}}{\abs{a_n}}\amp =\lim_{n\to\infty} \frac{\abs{\dfrac{k(k-1)\cdots(k-(n-1))(k-n)}{(n+1)!}x^{n+1}}}{\abs{\dfrac{k(k-1)\cdots\big(k-(n-1)\big)}{n!}x^n}}\\ \amp =\lim_{n\to\infty} \abs{\frac{k-n}{n+1}x}\\ \amp = \abs{x}\text{.} \end{align*}
The series converges absolutely when the limit of the Ratio Test is less than 1; therefore, we have absolute convergence when $$\abs{x}\lt 1\text{.}$$
While outside the scope of this text, the interval of convergence depends on the value of $$k\text{.}$$ When $$k \gt 0\text{,}$$ the interval of convergence is $$[-1,1]\text{.}$$ When $$-1\lt k\lt 0\text{,}$$ the interval of convergence is $$[-1,1)\text{.}$$ If $$k\leq -1\text{,}$$ the interval of convergence is $$(-1,1)\text{.}$$
We learned that Taylor polynomials offer a way of approximating a “difficult to compute” function with a polynomial. Taylor series offer a way of exactly representing a function with a series. One probably can see the use of a good approximation; is there any use of representing a function exactly as a series?
While we should not overlook the mathematical beauty of Taylor series (which is reason enough to study them), there are practical uses as well. They provide a valuable tool for solving a variety of problems, including problems relating to integration and differential equations.
In Key Idea 9.8.11 (on the following page) we give a table of the Taylor series of a number of common functions. We then give a theorem about the “algebra of power series,” that is, how we can combine power series to create power series of new functions. This allows us to find the Taylor series of functions like $$f(x) = e^x\cos(x)$$ by knowing the Taylor series of $$e^x$$ and $$\cos(x)\text{.}$$
Before we investigate combining functions, consider the Taylor series for the arctangent function (see Key Idea 9.8.11). Knowing that $$\tan^{-1}(1) = \pi/4\text{,}$$ we can use this series to approximate the value of $$\pi\text{:}$$
\begin{align*} \frac{\pi}4 \amp = \tan^{-1}(1) = 1-\frac13+\frac15-\frac17+\frac19-\cdots\\ \pi \amp = 4\left(1-\frac13+\frac15-\frac17+\frac19-\cdots\right) \end{align*}
Unfortunately, this particular expansion of $$\pi$$ converges very slowly. The first 100 terms approximate $$\pi$$ as $$3.13159\text{,}$$ which is not particularly good.

### Key Idea9.8.11.Important Taylor Series Expansions.

 Function and Series First Few Terms Interval of Convergence $$\ds e^x = \infser[0] \frac{x^n}{n!}$$ $$\ds 1+ x+\frac{x^2}{2!} + \frac{x^3}{3!}+\cdots$$ $$(-\infty,\infty)$$ $$\ds \sin(x) = \infser[0] (-1)^n\frac{x^{2n+1}}{(2n+1)!}$$ $$\ds x-\frac{x^3}{3!}+\frac{x^5}{5!} - \frac{x^7}{7!}+\cdots$$ $$(-\infty,\infty)$$ $$\ds \cos(x) = \infser[0] (-1)^n\frac{x^{2n}}{(2n)!}$$ $$\ds 1-\frac{x^2}{2!}+\frac{x^4}{4!} - \frac{x^6}{6!} +\cdots$$ $$(-\infty,\infty)$$ $$\ds \ln(x) = \infser(-1)^{n+1}\frac{(x-1)^n}{n}$$ $$\ds (x-1)- \frac{(x-1)^2}{2} +\frac{(x-1)^3}{3}-\cdots$$ $$(0,2]$$ $$\ds \frac{1}{1-x} = \infser[0] x^n$$ $$\ds 1+x+x^2+x^3+\cdots$$ $$(-1,1)$$ $$\ds \tan^{-1}(x) = \infser[0] (-1)^n\frac{x^{2n+1}}{2n+1}$$ $$\ds x-\frac{x^3}{3}+\frac{x^5}{5}-\frac{x^7}{7}+\cdots$$ $$[-1,1]$$ $$\ds (1+x)^k=\infser[0] \binom{k}{n}x^n$$ $$\ds 1+kx+\frac{k(k-1)}{2!}x^2 + \cdots$$ $$(-1,1)$$
Note that for $$(1+x)^k\text{,}$$ the interval of convergence may contain one or both endpoints, depending on the value of $$k\text{,}$$ and we are using the generalized binomial coefficients
\begin{equation*} \binom{k}{n} = \frac{k(k-1)\cdots (k-(n-1))}{n!}\text{.} \end{equation*}

### Example9.8.14.Combining Taylor series.

Write out the first 3 terms of the Taylor Series for $$f(x) = e^x\cos(x)$$ using Key Idea 9.8.11 and Theorem 9.8.12.
Solution 1. Video solution
Solution 2.
Key Idea 9.8.11 informs us that
\begin{equation*} e^x = 1+x+\frac{x^2}{2!}+\frac{x^3}{3!}+\cdots \text{ and } \cos(x) = 1-\frac{x^2}{2!}+\frac{x^4}{4!}+\cdots\text{.} \end{equation*}
Applying Theorem 9.8.12, we find that
\begin{equation*} e^x\cos(x) = \left(1+x+\frac{x^2}{2!}+\frac{x^3}{3!}+\cdots\right)\left(1-\frac{x^2}{2!}+\frac{x^4}{4!}+\cdots\right)\text{.} \end{equation*}
Distribute the right hand expression across the left:
\begin{align*} e^x\cos(x)\amp = 1\left(1-\frac{x^2}{2!}+\frac{x^4}{4!}+\cdots\right)+x\left(1-\frac{x^2}{2!}+\frac{x^4}{4!}+\cdots\right)\\ \amp + \frac{x^2}{2!}\left(1-\frac{x^2}{2!}+\frac{x^4}{4!}+\cdots\right)+\frac{x^3}{3!}\left(1-\frac{x^2}{2!}+\frac{x^4}{4!}+\cdots\right)\\ \amp + \frac{x^4}{4!}\left(1-\frac{x^2}{2!}+\frac{x^4}{4!}+\cdots\right)+\cdots \end{align*}
If we distribute again and collect like terms, we find
\begin{equation*} e^x\cos(x) = 1 + x -\frac{x^3}{3}-\frac{x^4}{6} - \frac{x^5}{30}+\frac{x^7}{630}+\cdots\text{.} \end{equation*}
While this process is a bit tedious, it is much faster than evaluating all the necessary derivatives of $$e^x\cos(x)$$ and computing the Taylor series directly.
Because the series for $$e^x$$ and $$\cos(x)$$ both converge on $$(-\infty,\infty)\text{,}$$ so does the series expansion for $$e^x\cos(x)\text{.}$$

### Example9.8.15.Creating new Taylor series.

Use Theorem 9.8.12 to create series for $$y=\sin(x^2)$$ and $$y=x^3/(3+x^4)\text{.}$$
Solution 1. Video solution
Solution 2.
Given that
\begin{equation*} \sin(x) = \infser[0] (-1)^n\frac{x^{2n+1}}{(2n+1)!} = x-\frac{x^3}{3!}+\frac{x^5}{5!} -\frac{x^7}{7!}+\cdots\text{,} \end{equation*}
we simply substitute $$x^2$$ for $$x$$ in the series, giving
\begin{align*} \sin(x^2) \amp = \infser[0] (-1)^n\frac{(x^2)^{2n+1}}{(2n+1)!}\\ \amp \infser[0] (-1)^n\frac{(x^{4n+2}}{(2n+1)!}\\ \amp =x^2-\frac{x^6}{3!}+\frac{x^{10}}{5!} -\frac{x^{14}}{7!}\cdots\text{.} \end{align*}
Since the Taylor series for $$\sin(x)$$ has an infinite radius of convergence, so does the Taylor series for $$\sin(x^2)\text{.}$$
For $$y=x^3/(3+x^4)\text{,}$$ we begin with the geometric series expansion
\begin{equation*} \frac{1}{1-x} = \sum_{n=0}^\infty x^n\text{.} \end{equation*}
Note that we can write
\begin{equation*} \frac{1}{3+x^4} = \frac13\cdot\frac{1}{1+x^4/3} = \frac13 \cdot \frac{1}{1-(-x^4/3)}\text{.} \end{equation*}
Substituting $$-x^4/3$$ into the geometric series expansion, we get
\begin{equation*} \frac{1}{3+x^4} = \sum_{n=0}^\infty (-x^4/3)^n = \sum_{n=0}^\infty \frac{(-1^n)x^{4n}}{3^n}\text{.} \end{equation*}
Finally, we can multiply both sides of the above equation by $$x^3$$ to obtain
\begin{equation*} \frac{x^3}{3+x^4} = x^3\sum_{n=0}^\infty \frac{(-1^n)x^{4n}}{3^n} = \sum_{n=0}^\infty \frac{(-1)^nx^{4n+3}}{3^n}\text{.} \end{equation*}

### Example9.8.16.A (somewhat foolish) combination of Taylor series.

Discuss possible methods for obtaining a Taylor series expansion for $$f(x)=\ln(\sqrt{x})\text{.}$$
Solution.
Since $$f(x)$$ is a composition, our first instict might be to apply Theorem 9.8.12 to the problem. However, $$\sqrt{x}$$ is not a polynomial function, and neither $$\ln(x)$$ nor $$\sqrt{x}$$ have Maclaurin series expansions.
You might already see a simple way to proceed, but let us first consider the following: $$\sqrt{x}=(1+(x-1))^{1/2}$$ can be expanded as a binomial series centered at $$x=1\text{.}$$ We also know the Taylor series for $$\ln(x)$$ at $$x=1\text{,}$$ and note that $$\sqrt{1}=1\text{,}$$ so when $$x$$ is near 1, so is $$\sqrt{x}\text{.}$$
What happens if we take the Taylor series
\begin{equation*} \ln(x) = \sum_{n=1}^\infty (-1)^{n+1}\frac{(x-1)^n}{n} = (x-1)-\frac{(x-1)^2}{2}+\frac{(x-1)^3}{3}-\cdots \end{equation*}
and substitute in
\begin{equation*} \sqrt{x} = \sum_{n=0}^\infty \binom{1/2}{n}(x-1)^n = 1+\frac12(x-1)-\frac14(x-1)^2+\cdots\text{,} \end{equation*}
where $$\binom{1/2}{n}=\frac{1/2(1/2-1)\cdots (1/2-(n-1))}{n!}$$ denotes the binomial coefficient?
Short answer: a mess. We have to replace each occurence of $$x-1$$ in the power series for $$\ln(x)$$ with $$\sqrt{x}-1 = \frac12(x-1)-\frac14(x-1)^2+\frac{1}{16}(x-1)^3+\cdots\text{,}$$ and then expand, and collect terms. If we do this, keeping only terms up to $$(x-1)^3\text{,}$$ we find:
\begin{align*} \ln(\sqrt{x}) \amp = \left(\frac12(x-1)-\frac14(x-1)^2+\frac{1}{16}(x-1)^3+\cdots\right)\\ \amp \quad -\frac12\left(\frac12(x-1)-\frac14(x-1)^2+\frac{1}{16}(x-1)^3+\cdots\right)^2 \\ \amp \quad + \frac13\left(\frac12(x-1)-\frac14(x-1)^2+\frac{1}{16}(x-1)^3+\cdots\right)+\cdots\\ \amp = \frac12(x-1)-\frac14(x-2)^2+\frac16(x-1)^3-\cdots\text{.} \end{align*}
But of course, there was a better way all along:
\begin{equation*} \ln(\sqrt{x}) = \ln(x^{1/2}) = \frac12\ln(x) \end{equation*}
using properties of the logarithm, and indeed, the result above is the same as the one we would have obtained by simply multiplying the Taylor series for $$\ln(x)$$ by $$\frac12\text{.}$$ Power series manipulation is a powerful technique, but one should not apply it blindly.

### Example9.8.17.Using Taylor series to approximate a composition.

Use Taylor series to determine a degree 5 Taylor polynomial approximation to $$f(x)=e^{\sin(x)}\text{.}$$
Solution.
Here we want to apply Theorem 9.8.12, but $$h(x)=\sin(x)$$ is not a polynomial. However, we are interested in approximation, so we replace $$\sin(x)$$ by the Maclaurin polynomial
\begin{equation*} q(x) = x - \frac{x^3}{3!} + \frac{x^5}{5!}\text{.} \end{equation*}
The Maclaurin series for $$f(x)=e^x$$ is given by
\begin{equation*} e^x = \sum_{n=0}^\infty \frac{x^n}{n!}\text{.} \end{equation*}
Next, we substitute $$q(x)$$ into the series for $$e^x\text{.}$$ The algebra gets very messy, but we can simplify things: since we want the degree 5 approximation, there is no need to write down terms involving $$x^6$$ or higher powers.
\begin{align*} e^{\sin(x)} \amp \approx 1 + q(x) + \frac{1}{2!}q(x)^2+\frac{1}{3!}q(x)^3+\frac{1}{4!}q(x)^4+\frac{1}{5!}q(x)^5\\ \amp = 1 + \left(x-\frac{x^3}{6}+\frac{x^5}{120}\right) + \frac12\left(x-\frac{x^3}{6}+\frac{x^5}{120}\right)\\ \amp \quad + \frac{1}{6}\left(x-\frac{x^3}{6}+\frac{x^5}{120}\right)^3 + \frac{1}{24}\left(x-\frac{x^3}{6}+\frac{x^5}{120}\right)^4 \\ \amp \quad\quad + \frac{1}{120}\left(x-\frac{x^3}{6}+\frac{x^5}{120}\right)^5\\ \amp = 1+x-\frac{x^3}{6}+\frac{x^5}{120}+\frac12\left(x^2-\frac13x^4+\cdots\right)+\frac16\left(x^3-\frac12x^5+\cdots\right)\\ \amp \quad + \frac{1}{24}\left(x^4+\cdots\right) + \frac{1}{120}\left(x^5+\cdots\right)\\ \amp = 1+x+\frac12x^2-\frac18x^4-\frac{1}{15}x^5+\cdots\text{.} \end{align*}
While the algebra is a bit of a mess, it is often less work than computing the Taylor polynomial directly, as the derivatives of a composite function quickly get complicated. The function $$f(x)=e^{\sin(x)}$$ and its approximation are plotted in Figure 9.8.18 below. Note that our polynomial approximation is very good on $$[-1,1]\text{.}$$
In the previous example, the reader might be left wondering why we would bother with all that algebra, when the computer could have given us the result in seconds. One reason is simply that it lets us see how these different pieces fit together. Computing a Taylor polynomial by combining existing results will give the same polynomial as computing derivatives. Also we see that we can compute an approximation by replacing both parts of a composition with approximations. In the last couple of examples in this chapter, we see another reason: often we have to define functions in terms of power series derived through integration, or the solution of a differential equation, where there is no known function we can simply plug into the computer.

### Example9.8.19.Using Taylor series to evaluate definite integrals.

Use the Taylor series of $$e^{-x^2}$$ to evaluate $$\ds \int_0^1e^{-x^2}\, dx\text{.}$$
Solution 1. Video solution
Solution 2.
We learned, when studying Numerical Integration, that $$e^{-x^2}$$ does not have an antiderivative expressible in terms of elementary functions. This means any definite integral of this function must have its value approximated, and not computed exactly.
We can quickly write out the Taylor series for $$e^{-x^2}$$ using the Taylor series of $$e^x\text{:}$$
\begin{align*} e^x \amp = \infser[0] \frac{x^n}{n!} = 1+x+\frac{x^2}{2!}+\frac{x^3}{3!}+\cdots\\ \end{align*}

and so

\begin{align*} e^{-x^2} \amp = \infser[0] \frac{(-x^2)^n}{n!}\\ \amp = \infser[0] (-1)^n\frac{x^{2n}}{n!}\\ \amp = 1-x^2+\frac{x^4}{2!}-\frac{x^6}{3!}+\cdots\text{.} \end{align*}
We use Theorem 9.6.9 to integrate:
\begin{equation*} \int e^{-x^2}\, dx = C + x - \frac{x^3}{3}+\frac{x^5}{5\cdot2!}-\frac{x^7}{7\cdot3!}+\cdots +(-1)^n\frac{x^{2n+1}}{(2n+1)n!}+\cdots \end{equation*}
This is the antiderivative of $$e^{-x^2}\text{;}$$ while we can write it out as a series, we cannot write it out in terms of elementary functions. We can evaluate the definite integral $$\ds \int_0^1e^{-x^2}\, dx$$ using this antiderivative; substituting 1 and 0 for $$x$$ and subtracting gives
\begin{equation*} \int_0^1e^{-x^2}\, dx = 1-\frac{1}{3}+\frac{1}{5\cdot 2!}-\frac{1}{7\cdot3!} + \frac{1}{9\cdot4!}\cdots\text{.} \end{equation*}
Summing the 5 terms shown above give the approximation of $$0.74749\text{.}$$ Since this is an alternating series, we can use the Alternating Series Approximation Theorem, (Theorem 9.5.7), to determine how accurate this approximation is. The next term of the series is $$1/(11\cdot5!) \approx 0.00075758\text{.}$$ Thus we know our approximation is within $$0.00075758$$ of the actual value of the integral. This is arguably much less work than using Simpson's Rule to approximate the value of the integral.

### Example9.8.20.Using Taylor series to solve differential equations.

Solve the differential equation $$y'=2y$$ in terms of a power series, and use the theory of Taylor series to recognize the solution in terms of an elementary function.
Solution 1. Video solution
Solution 2.
We found the first 5 terms of the power series solution to this differential equation in Example 9.6.13 in Section 9.6. These are:
\begin{equation*} a_0=1, a_1 = 2, a_2 = \frac42=2, a_3=\frac{8}{2\cdot3}=\frac43, a_4=\frac{16}{2\cdot3\cdot4} = \frac23\text{.} \end{equation*}
We include the “unsimplified” expressions for the coefficients found in Example 9.6.13 as we are looking for a pattern. It can be shown that $$a_n = 2^n/n!\text{.}$$ Thus the solution, written as a power series, is
\begin{equation*} y = \infser[0] \frac{2^n}{n!}x^n = \infser[0] \frac{(2x)^n}{n!}\text{.} \end{equation*}
Using Key Idea 9.8.11 and Theorem 9.8.12, we recognize $$f(x) = e^{2x}\text{:}$$
\begin{equation*} e^x = \infser[0] \frac{x^n}{n!} \qquad \Rightarrow \qquad e^{2x} = \infser[0] \frac{(2x)^n}{n!}\text{.} \end{equation*}
Finding a pattern in the coefficients that match the series expansion of a known function, such as those shown in Key Idea 9.8.11, can be difficult. What if the coefficients in the previous example were given in their reduced form; how could we still recover the function $$y=e^{2x}\text{?}$$
Suppose that all we know is that
\begin{equation*} a_0=1, a_1=2, a_2=2, a_3=\frac43, a_4=\frac23\text{.} \end{equation*}
Definition 9.8.2 states that each term of the Taylor expansion of a function includes an $$n!\text{.}$$ This allows us to say that
\begin{equation*} a_2=2=\frac{b_2}{2!}, a_3 = \frac43=\frac{b_3}{3!}, \text{ and } a_4 = \frac23=\frac{b_4}{4!} \end{equation*}
for some values $$b_2\text{,}$$ $$b_3$$ and $$b_4\text{.}$$ Solving for these values, we see that $$b_2=4\text{,}$$ $$b_3 = 8$$ and $$b_4=16\text{.}$$ That is, we are recovering the pattern we had previously seen, allowing us to write
\begin{align*} f(x) = \infser[0] a_nx^n \amp = \infser[0] \frac{b_n}{n!}x^n\\ \amp = 1+2x+ \frac{4}{2!}x^2 + \frac{8}{3!}x^3+\frac{16}{4!}x^4 + \cdots \end{align*}
From here it is easier to recognize that the series is describing an exponential function.
There are simpler, more direct ways of solving the differential equation $$y' = 2y\text{,}$$ as discussed in Chapter 8. We applied power series techniques to this equation to demonstrate its utility, and went on to show how sometimes we are able to recover the solution in terms of elementary functions using the theory of Taylor series. Most differential equations faced in real scientific and engineering situations are much more complicated than this one, but power series can offer a valuable tool in finding, or at least approximating, the solution.
This chapter introduced sequences, which are ordered lists of numbers, followed by series, wherein we add up the terms of a sequence. We quickly saw that such sums do not always add up to “infinity,” but rather converge. We studied tests for convergence, then ended the chapter with a formal way of defining functions based on series. Such “series-defined functions” are a valuable tool in solving a number of different problems throughout science and engineering.
Coming in the next chapters are new ways of defining curves in the plane apart from using functions of the form $$y=f(x)\text{.}$$ Curves created by these new methods can be beautiful, useful, and important.

### ExercisesExercises

#### Terms and Concepts

##### 1.
What is the difference between a Taylor polynomial and a Taylor series?
##### 2.
What theorem must we use to show that a function is equal to its Taylor series?

#### Problems

##### Exercise Group.
Key Idea 9.8.11 gives the $$n$$th term of the Taylor series of common functions. In the following exercises, verify the formula given in the Key Idea by finding the first few terms of the Taylor series of the given function and identifying a pattern.
###### 3.
$$f(x) = e^x\text{;}$$$$c=0$$
###### 4.
$$f(x) = \sin(x)\text{;}$$$$c=0$$
###### 5.
$$f(x) = 1/(1-x)\text{;}$$$$c=0$$
###### 6.
$$f(x) = \tan^{-1}(x)\text{;}$$$$c=0$$
##### Exercise Group.
In the following exercises, find a formula for the $$n$$th term of the Taylor series of $$f(x)\text{,}$$ centered at $$c\text{,}$$ by finding the coefficients of the first few powers of $$x$$ and looking for a pattern. (The formulas for several of these are found in Key Idea 9.8.11; show work verifying these formula.)
###### 7.
$$f(x) = \cos(x)\text{;}$$$$c=\pi/2$$
###### 8.
$$f(x) = 1/x\text{;}$$$$c=1$$
###### 9.
$$f(x) = e^{-x}\text{;}$$$$c=0$$
###### 10.
$$f(x) = \ln(1+x)\text{;}$$$$c=0$$
###### 11.
$$f(x) = x/(x+1)\text{;}$$$$c=1$$
###### 12.
$$f(x) = \sin(x)\text{;}$$$$c=\pi/4$$
##### Exercise Group.
In the following exercises, show that the Taylor series for $$f(x)\text{,}$$ as given in Key Idea 9.8.11, is equal to $$f(x)$$ by applying Theorem 9.8.7; that is, show $$\lim\limits_{n\to\infty}R_n(x) =0\text{.}$$
###### 13.
$$f(x) = e^x$$
###### 14.
$$f(x) = \sin(x)$$
###### 15.
$$f(x) = \ln(x)$$ (show equality only on $$(1,2)$$)
###### 16.
$$f(x) = 1/(1-x)$$ (show equality only on $$(-1,0)$$)
##### Exercise Group.
In the following exercises, use the Taylor series given in Key Idea 9.8.11 to verify the given identity.
###### 17.
$$\cos(-x) = \cos(x)$$
###### 18.
$$\sin(-x) = -\sin(x)$$
###### 19.
$$\frac{d}{dx}\big(\sin(x) \big) = \cos(x)$$
###### 20.
$$\frac{d}{dx}\big(\cos(x) \big) = -\sin(x)$$
##### Exercise Group.
In the following exercises, write out the first 5 terms of the Binomial series with the given $$k$$-value.
###### 21.
$$k=1/2$$
###### 22.
$$k=-1/2$$
###### 23.
$$k=1/3$$
###### 24.
$$k=4$$
##### Exercise Group.
In the following exercises, use the Taylor series given in Key Idea 9.8.11 to create the Taylor series of the given functions.
###### 25.
$$f(x) = \cos\big(x^2\big)$$
###### 26.
$$f(x) = e^{-x}$$
###### 27.
$$f(x) = \sin\big(2x+3\big)$$
###### 28.
$$f(x) = \tan^{-1}\big(x/2\big)$$
###### 29.
$$f(x) = e^x\sin(x)$$(only find the first 4 terms)
###### 30.
$$f(x) = (1+x)^{1/2}\cos(x)$$(only find the first 4 terms)
##### Exercise Group.
In the following exercises, approximate the value of the given definite integral by using the first 4 nonzero terms of the integrand's Taylor series.
###### 31.
$$\ds \int_0^{\sqrt{\pi}} \sin\big(x^2\big)\, dx$$
###### 32.
$$\ds \int_0^{\sqrt[3]{\pi}} \cos\left(x^3\right)\, dx$$