Skip to main content

Unit 14.3 Computing Taylor Polynomials

There’s always at least one way to compute a Taylor polynomial: use the formula in Definition 14.2. But that usually involves taking a lot of derivatives, which might not be so helpful if the function in question is complicated. So instead, we’re going to approach the computation of Taylor polynomials the way we approached computing derivatives and integrals: list out the Taylor polynomials for some basic functions, and then state some rules for how the Taylor polynomial of a complicated function is related to those of its parts.
The basic idea behind all these rules is: Taylor polynomials are polynomials -- so you can do all of the lovely algebra to them that you learned in middle and high school.
Table 14.10. Some common Maclaurin polynomials.
\(f(x)\) Maclaurin polynomial of degree 4
\(e^x\) \(1+x+\frac{1}{2}x^2+\frac{1}{6}x^3+\frac{1}{24}x^4\)
\(\sin(x)\) \(x-\frac{1}{6}x^3\)
\(\cos(x)\) see Checkpoint 195
\(\frac{1}{1-x}\) \(1+x+x^2+x^3+x^4\)
\(\frac{1}{1+x}\) \(1-x+x^2-x^3+x^4\)
\(\ln(1+x)\) \(x-\frac{1}{2}x^2+\frac{1}{3}x^3-\frac{1}{4}x^4\)

Subsection 14.3.1 Simple Compositions

Let’s say we want to compute the degree-8 Maclaurin polynomial for \(f(x)=\sin(x^2)\text{.}\) We could go ahead and differentiate 8 times. But to save ourselves some work, let’s switch variables. Set \(t=x^2\text{.}\) Table 14.10 tells us that
\begin{equation*} \sin(t)\approx t-\frac{1}{6}t^3 \end{equation*}
and that this is the best approximation by a polynomial which is degree 4 in \(t\text{.}\) Notice that being degree 4 in \(t\) is the same as being degree 8 in \(x\text{.}\) If we substitute \(t=x^2\) back into our polynomial, we get:
\begin{equation*} \sin(x^2)\approx x^2-\frac{1}{6}x^6 \end{equation*}
which is our answer.
This trick works with powers of \(x\) and multiples of \(x\text{.}\) For example, the degree-5 Maclaurin polynomial for \(f(x)=e^{3x}\) is
\begin{gather*} 1+(3x)+\frac{1}{2}(3x)^2+\frac{1}{6}(3x)^3+\frac{1}{24}(3x)^4+\frac{1}{120}(3x)^5\\ =1+3x+\frac{9}{2}x^2+\frac{27}{6}x^3+\frac{81}{24}x^3+\frac{243}{120}x^5 \end{gather*}
That is, we can compose Maclaurin polynomials as just as long as the inside function sends 0 to 0.
If we want to allow for a shift of the center, that’s fine too.

Example 14.12.

Let’s compute the degree-3 Taylor polynomial, centered at \(x=-1\text{,}\) for \(\ln(2+x)=\ln(1+(x+1))\text{.}\) To do this, we use \(t=x+1\) and use the Maclaurin polynomial for \(\ln(1+t)\text{,}\) which is \(t-\frac{1}{2}t^2+\frac{1}{3}t^3\text{.}\) Plugging in \(t=x+1\) yields
\begin{equation*} x+1-\frac{1}{2}(x+1)^2+\frac{1}{3}(x+1)^3 \end{equation*}
Notice that the result is a polynomial in \(x+1\text{,}\) which means the center has to be \(x=-1\text{.}\)

Subsection 14.3.2 Products

Let’s say we want to compute the degree-6 Maclaurin polynomial for the function \(h(x)=e^x\sin(x)\text{.}\) To use the formula in Definition 14.2, we would have to take sixth derivatives. Because of the product rule, \(h'(x)\) will have two terms; \(h''(x)\) will have four terms; etc. So that seems like kind of a mess. On the other hand, Table 14.10 tells us that
\begin{align*} e^x\amp\approx 1+x+\frac{1}{2}x^2+\frac{1}{6}x^3+\frac{1}{24}x^4+\frac{1}{120}x^5+\frac{1}{720}x^6\\ \sin(x)\amp\approx x-\frac{1}{6}x^3+\frac{1}{120}x^5 \end{align*}
The Taylor polynomials are polynomials, so let’s treat them like polynomials and multiply!

Checkpoint 196.

When we multiply the degree-6 Maclaurin polynomial for \(e^x\) and the degree-6 Maclaurin polynomial for \(\sin(x)\text{,}\) we obtain a polynomial of degree which has terms before combining like terms.
Answer 1.
\(11\)
Answer 2.
\(21\)
Let’s go ahead and do the multiplication. I’ve color-coded the terms coming from \(e^x\) to help with the bookkeeping.
\begin{align*} e^x\sin(x)\approx\amp \left({\color{blue}{1}}+{\color{red}{x}}+{\color{green}{\frac{1}{2}x^2}}+{\color{orange}{\frac{1}{6}x^3}}+{\color{magenta}{\frac{1}{24}x^4}}+{\color{cyan}{\frac{1}{120}x^5}}+{\color{gray}{\frac{1}{720}x^6}}\right)\left(x-\frac{1}{3}x^3+\frac{1}{120}x^5\right)\\ \approx\amp{\color{blue}{1}}\left(x-\frac{1}{6}x^3+\frac{1}{120}x^5\right)\\ \amp+{\color{red}{x}}\left(x-\frac{1}{6}x^3+\frac{1}{120}x^5\right)\\ \amp+{\color{green}{\frac{1}{2}x^2}}\left(x-\frac{1}{6}x^3+\frac{1}{120}x^5\right)\\ \amp+{\color{orange}{\frac{1}{6}x^3}}\left(x-\frac{1}{6}x^3+\frac{1}{120}x^5\right)\\ \amp+{\color{magenta}{\frac{1}{24}x^4}}\left(x-\frac{1}{6}x^3+\frac{1}{120}x^5\right)\\ \amp+{\color{cyan}{\frac{1}{120}x^5}}\left(x-\frac{1}{6}x^3+\frac{1}{120}x^5\right)\\ \amp+{\color{gray}{\frac{1}{720}x^6}}\left(x-\frac{1}{6}x^3+\frac{1}{120}x^5\right)\\ \approx\amp {\color{blue}{x-\frac{1}{6}x^3+\frac{1}{120}x^5}}\\ \amp+{\color{red}{x^2-\frac{1}{6}x^4+\frac{1}{120}x^6}}\\ \amp+{\color{green}{\frac{1}{2}x^3-\frac{1}{12}x^5+\frac{1}{240}x^7}}\\ \amp+\cdots \end{align*}
I’ve left off the remaining rows; you are an expert at manipulating polynomials so you can complete them yourself. But I want to point something out here: there are lots of terms with degrees greater than 6. Because we want a polynomial of degree 6, we can just omit these.

Checkpoint 197.

What is the degree-6 Maclaurin polynomial for \(e^x\sin(x)\text{?}\)
Answer.
\(x+x^{2}+0.333333x^{3}+0x^{4}+\left(-0.0333333\right)x^{5}+\left(-0.0111111\right)x^{6}\)

Subsection 14.3.3 More Complicated Compositions

We can also use it with more complicated compositions such as \(f(x)=\cos(e^x-1)\text{.}\) Let’s find the degree-3 Maclaurin polynomial for \(\cos(e^x-1)\text{.}\) We start with the degree-3 Maclaurin polynomial for \(\cos(t)\text{,}\) applied with \(t=e^x-1\text{:}\)
\begin{equation*} \cos(e^x-1)\approx 1-\frac{1}{2}\left(e^x-1\right)^2 \end{equation*}
Now, we remind ourselves that \(e^x\approx 1+x+\frac{1}{2}x^2+\frac{1}{6}x^3\text{,}\) so that \(t=e^x-1\sim x+\frac{1}{2}x^2+\frac{1}{6}x^3\text{,}\) and make that substitution:
\begin{equation*} \cos(e^x-1)\sim 1-\frac{1}{2}\left(x+\frac{1}{2}x^2+\frac{1}{6}x^3\right)^2 \end{equation*}
Like we did with products, now we bite the bullet and do the algebra:
\begin{align*} 1-\frac{1}{2}&\left(x+\frac{1}{2}x^2+\frac{1}{6}x^3\right)^2\\ &=1-\frac{1}{2}\left(x^2+\left(\frac{1}{2}x^2\right)^2+\left(\frac{1}{6}x^3\right)^2+2x\frac{1}{2}x^2+2x\frac{1}{6}x^3+2\frac{1}{2}x^2\frac{1}{6}x^3\right)\\ &=1-\frac{1}{2}x^2-\frac{1}{3}x^3-\frac{7}{24}x^4-\frac{1}{12}x^5-\frac{1}{72}x^6 \end{align*}
Notice that we actually got a degree 6 polynomial. Since we only needed to approximate \(f\) to order 3, we take the cubic part and our answer is:
\begin{equation*} P_3(x)=\frac{1}{2}-\frac{1}{2}x^2-\frac{1}{6}x^3\ \ \ . \end{equation*}
Plotting \(P_3\) together with \(f\) confirms that this is a good approximation, at least near \(x=0\text{:}\)
Figure 14.13. \(P_3\) (purple) and \(f(x)=\cos(e^x-1)\) (black).

Subsection 14.3.4 Putting it together: Taylor series

You may have noticed in the examples above that there’s a lot of handwaving going on with counting degrees and figuring out which terms we need to pay attention to and which we can disregard. There’s a nice method to do this accounting, but it requires a little mental flexibility.

Definition 14.14.

The Taylor series for a function \(f(x)\text{,}\) centered at \(x=c\text{,}\) is the sum
\begin{equation*} f(c)+f'(c)(x-c)+\frac{1}{2}f''(c)(x-c)^2+\frac{1}{3!}f'''(c)(x-c)^3+\cdots \end{equation*}
That is, the Taylor series is just a Taylor polynomial that doesn’t stop.
When \(c=0\text{,}\) we call this the Maclaurin series:
\begin{equation*} f(0)+f'(0)x+\frac{1}{2}f''(0)x^2+\frac{1}{3!}f'''(0)x^3+\cdots \end{equation*}
I think of the Taylor series as really being a shorthand for all the Taylor polynomials of different degrees.
The sum in Definition 14.14 has infinitely many terms, so you might think we’re going to veer off into questions of whether or not it converges. That’s a topic for MATH 1080. But for right now, we’re just going to use Taylor series without caring too much.
So, for example, we can write
\begin{equation*} e^x=1+x+\frac{1}{2}x^2+\frac{1}{3!}x^3+\frac{1}{4!}x^4+\cdots \end{equation*}
and
\begin{equation*} \cos(x)=1-\frac{1}{2}x^2+\frac{1}{4!}x^4-\frac{1}{6!}x^6+\cdots \end{equation*}
Then, in order to use the approaches described above, we just have to ACTUALLY BELIEVE THESE EQUAL SIGNS. Here’s an

Example 14.16.

Let’s compute the degree-4 Maclaurin polynomial for \(f(x)=e^{\sin x}\text{.}\) We know that
\begin{equation*} e^t=1+t+\frac{1}{2!}t^2+\frac{1}{3!}t^3+\frac{1}{4!}t^4\cdots \end{equation*}
so we "just" plug in \(t=\sin x\text{:}\)
\begin{equation*} e^{\sin x}=1+\sin x+\frac{1}{2!}(\sin x)^2+\frac{1}{3!}(\sin x)^3+\cdots \end{equation*}
and then we "just" plug in the fact that and \(sin(x)=x-\frac{1}{3!}x^3+\frac{1}{5!}x^5-\frac{1}{7!}x^7+\cdots\text{:}\)
\begin{align*} e^{\sin x}=&1+\left(x-\frac{1}{3!}x^3+\frac{1}{5!}x^5-\frac{1}{7!}x^7+\cdots\right)\\ &+\frac{1}{2!}\left(x-\frac{1}{3!}x^3+\frac{1}{5!}x^5-\frac{1}{7!}x^7+\cdots\right)^2\\ &+\frac{1}{3!}\left(x-\frac{1}{3!}x^3+\frac{1}{5!}x^5-\frac{1}{7!}x^7+\cdots\right)^3\\ &+\frac{1}{4!}\left(x-\frac{1}{3!}x^3+\frac{1}{5!}x^5-\frac{1}{7!}x^7+\cdots\right)^4\\ &+\cdots \end{align*}
Now we have some algebraic work to do. We’ve been asked to look at the degree-4 part of all this, so anything with a power of \(x\) greater than 4 is irrelevant to us. That means the interior \(\cdots\text{,}\) which have a minimum degree of 9, don’t concern us. Furthermore, the terms involving \(x^5\) and \(x^7\) already have too high a degree. So we can toss those into the \(\cdots\text{,}\) too, leaving the much-cleaner-looking
\begin{align*} e^{\sin x}=&1+\left(x-\frac{1}{3!}x^3+\cdots\right)\\ &+\frac{1}{2!}\left(x-\frac{1}{3!}x^3+\cdots\right)^2\\ &+\frac{1}{3!}\left(x-\frac{1}{3!}x^3+\cdots\right)^3\\ &+\frac{1}{4!}\left(x-\frac{1}{3!}x^3+\cdots\right)^4\\ &+\cdots \end{align*}
Let’s take a look at the second line. Expanding it out using the formula \((a+b)^2=a^2+2ab+b^2\text{:}\)
\begin{equation*} \frac{1}{2!}\left(x-\frac{1}{3!}x^3+\cdots\right)^2=\frac{1}{2!}\left(x^2-\frac{2}{3!}x\cdot x^3+\left(\frac{1}{3!}x^3\right)^2\right) \end{equation*}
and the last term, \(\left(\frac{1}{3!}x^3\right)^2\text{,}\) has degree 6 -- more than we care about. So this line contributes
\begin{equation*} \frac{1}{2!}x^2-\frac{2}{2!3!}x^4+\cdots \end{equation*}
In the third line, we need to use the formula \((a+b)^3=a^3+3a^2b+3ab^2+b^3\text{:}\)
\begin{align*} \frac{1}{3!}&\left(x-\frac{1}{3!}x^3+\cdots\right)^3\\ &=\frac{1}{3!}\left(x^3-\frac{3}{3!}x^2\cdot x^3+3\left(\frac{1}{3!}\right)^2 x\cdot x^6-\left(\frac{1}{3!}\right)x^9\right)+\cdots \end{align*}
Here the terms have degrees 3, 5, 7, and 9 respectively. Only the first is relevant to us.
For the fourth line, the algebra we need is \((a+b)^4=a^4+4a^3b+6a^2b^2+4ab^3+b^4\) and hopefully you can see that again on the first term is relevant to us.
Putting it all together yields
\begin{equation*} 1+x-\frac{1}{3!}x^3+\frac{1}{2!}x^2-\frac{2}{2!3!}x^4+\frac{1}{3!}x^3+\frac{1}{4!}x^4 \end{equation*}
which we ought to clean up to
\begin{equation*} 1+x+\frac{1}{2!}x^2+\left(\frac{1}{4!}-\frac{1}{3!}\right)x^4 \end{equation*}