## Taylor Series

0. Can we approximate a function using a power series?

With the calculus’ help, we can!

1. Consider the function
(1)$\displaystyle f(x) = \sum^{\infty}_{n=0}b_{n}(x-a)^{n} = b_{0} + b_{1}(x-a) + \dots.$
We suppose it is smooth (i.e., has infinitely many derivatives). We see
(2)\displaystyle \begin{aligned} f'(x) &= \sum^{\infty}_{n=1}b_{n}n(x-a)^{n-1}\\ f'(a) &= b_{1} \end{aligned}
and
(3)\displaystyle \begin{aligned} f''(x) &= \sum^{\infty}_{n=2}b_{n}n(n-1)\cdot(x-a)^{n-2}\\ f''(a) &= 2b_{2}. \end{aligned}
We also have
(4)\displaystyle \begin{aligned} f'''(x) &= \sum^{\infty}_{n=3}b_{n}n(n-1)(n-2)\cdot(x-a)^{n-3}\\ f'''(a) &= 3\cdot2\cdot1 b_{3} = 6b_{3}. \end{aligned}
The general case appears to be
(5)$\displaystyle \left.\frac{\mathrm{d}^{n}}{\mathrm{d} x^{n}}f(x)\right|_{x=a}=n! b_{n}$
Thus the coefficients are
(6)$\displaystyle b_{n} = \left.\frac{1}{n!}\frac{\mathrm{d}^{n}}{\mathrm{d} x^{n}}f(x)\right|_{x=a}$
and we can reconstruct the function ${f(x)}$.

2. Definition. Let ${f(x)}$ be any function. The “Taylor Series about ${x=a}$ is a series
(7)$\displaystyle \sum^{\infty}_{n=0}f^{(n)}(a)\cdot(x-a)^{n}$
When ${a=0}$, it’s called a MacLaurin Series.

Remark 1. If we have the MacLaurin series for a function, and if the series converges for any value of ${x}$, then we can use the MacLaurin series as a synonym for the original function. That’s the usefulness of MacLaurin series.

Remark 2. The Taylor series helps us compute ${f(x+h)}$ when ${h\ll x}$ and when ${f(x)}$ is known. For example, ${\sqrt{1.001}}$ can be computed using the Taylor series of ${\sqrt{1+x}}$ about ${x=1}$.

Example 1. Consider the function ${\exp(x)}$. We see that
(8)$\displaystyle \frac{\mathrm{d}\exp(x)}{\mathrm{d} x}=\exp(x).$
Thus the MacLaurin series for the exponential function is
(9)$\displaystyle \exp(x)=\sum^{\infty}_{n=0}\frac{x^{n}}{n!}$
Where does this series converge?

Using the absolute ratio test, we find
(10)$\displaystyle \lim_{n\rightarrow\infty}\frac{x^{n+1}/(n+1)!}{x^{n}/n!} = \lim_{n\rightarrow\infty}\frac{x}{n+1}=0.$
So the series converges for any value of ${x}$.

Example 2. Consider the sine function ${\sin(x)}$. What is its MacLaurin series? Writing
(11)$\displaystyle \sum^{\infty}_{n=0}c_{n}x^{n}=\sin(x)$
we have
(12)\displaystyle \begin{aligned} c_{0}&=\sin(0)=0\\ c_{1}&=\cos(0)=1\\ c_{2}&=\frac{-\sin(0)}{2!}=0\\ c_{3}&=\frac{-\cos(0)}{3!}=-1/3! \end{aligned}
The coefficients are sort of “periodic” in the sense that only the odd ones remain, and their sign alternates. We have
(13)$\displaystyle c_{n} = c_{2k-1} = \frac{(-1)^{n}}{n!} = \frac{(-1)^{k+1}}{(2k-1)!}$
thus the MacLaurin series is
(14)$\displaystyle \sin(x)=\sum^{\infty}_{n=1}\frac{(-1)^{n+1}x^{n}}{(2n-1)!}.$
Where does this converge?

Using the ratio test, we have
(15)$\displaystyle \lim_{n\rightarrow\infty}\left|\frac{\left(\displaystyle\frac{x^{2n+3}}{(2n+3)!}\right)}{\left(\displaystyle\frac{x^{2n+1}}{(2n+1)!}\right)}\right| =\lim_{n\rightarrow\infty}\frac{x^{2}}{(2n+1)(2n+2)} = 0.$
Thus it converges for any value of ${x}$.

Example 3. Lets find the MacLaurin series for ${\cos(x)}$. We see that
(16)$\displaystyle \cos(x)=\sum^{\infty}_{n=0}b_{n}x^{n},$
we need to find the ${b_{n}}$. We see that
(17)\displaystyle \begin{aligned} b_{0} &= \cos(0) = 1\\ b_{1} &= -\sin(0) = 0\\ b_{2} &= \frac{-1}{2!}\cos(0) = -1/2\\ b_{3} &= \frac{1}{3!}\sin(0) = 0\\ b_{2k} &= \frac{(-1)^{k}}{(2k)!} \end{aligned}
So we have the MacLaurin series be
(18)$\displaystyle \cos(x) = \sum^{\infty}_{n=0}\frac{(-1)^{n}}{(2n)!}x^{2n}.$
Where will it converge? Using the absolute ratio test, we have
(19)\displaystyle \begin{aligned} \lim_{n\rightarrow\infty}\left|\frac{\left(\displaystyle\frac{(-1)^{n+1}x^{2n+2}}{(2n+2)!}\right)}{\left(\displaystyle\frac{(-1)^{n}x^{2n}}{(2n)!}\right)}\right| &=\lim_{n\rightarrow\infty}\frac{x^{2}}{(2n+1)(2n+2)}\\ &=0. \end{aligned}
Thus the MacLaurin series for ${\cos(x)}$ converges for any value of ${x}$.

3. Euler’s Formula. Recall Euler’s formula states
(20)$\displaystyle \exp(\mathrm{i}\theta)=\cos(\theta)+\mathrm{i}\sin(\theta)$
and we have the MacLaurin series for ${\exp(x)}$. Setting ${x=\mathrm{i}\theta}$, we find
(21)\displaystyle \begin{aligned} \exp(\mathrm{i}\theta) &= \sum^{\infty}_{n=0}\frac{(\mathrm{i}\theta)^{n}}{n!}\\ &=1+\mathrm{i}\theta-\frac{\theta^{2}}{2!}-\frac{\mathrm{i}\theta^{3}}{3!}+\frac{\theta^{4}}{4!}+\dots \end{aligned}
Gathering the real and imaginary parts together we get
(22)$\displaystyle \exp(\mathrm{i}\theta) = \left(\sum^{\infty}_{n=0}\frac{(-1)^{n}x^{2n}}{(2n)!}\right) +\mathrm{i}\left(\sum^{\infty}_{n=0}\frac{(-1)^{n}x^{2n+1}}{(2n+1)!}\right)$
But look: the imaginary part is precisely the MacLaurin series for ${\sin(x)}$! And the real part is the MacLaurin series for ${\cos(x)}$, too! So what did we do? We just derived Euler’s formula.

4. Taylor Series Makes Approximations Consider the function
(23)$\displaystyle f(x)=\sqrt{x}.$
Its Taylor series about ${x=1}$ is the same as the MacLaurin series for the function
(24)$\displaystyle g(h)=\sqrt{1+h}.$
Just write ${x=1+h}$. For small ${0, we can use the first couple of terms in the Taylor series as an approximate value. So what’s the first 6 nonzero terms in the Taylor series? We see
(25)$\displaystyle f(x)=x^{1/2}\quad\implies\quad f(1)=1$
describes the constant term. The linear term has coefficient
(26)$\displaystyle f'(x)=\frac{x^{-1/2}}{2}\quad\implies\quad f'(1)=\frac{1}{2}.$
(27)$\displaystyle f''(x)=\frac{-x^{-3/2}}{2^{2}}\quad\implies\quad f''(1)=-1/2^{2}.$
Observe how the exponent behaves when differentiating: ${(1/2)-n}$. The numerator is always odd, the denominator doesn’t change. So the ${n^{th}}$ derivative would be
(28)$\displaystyle f^{(n)}(x)=\frac{1\cdot3\cdot5\cdot(\dots)\cdot(2n-1)}{2^{n}}(-1)^{n-1}x^{(1-2n)/2}$
This gives us our coefficients! We then have
(29)$\displaystyle c_{n} = \frac{(-1)^{n-1}(2n)!}{(n!2^{n})^{2}}$
for ${n>0}$. Observe the numerator appears odd, but we can justify it thus:
(30)\displaystyle \begin{aligned} \frac{(2n)!}{n!2^{n}} &= \frac{1\cdot2\cdot3\cdot(\dots)\cdot(2n)}{(1\cdot2\cdot(\dots)\cdot n)2^{n}}\\ &= \frac{\bigl(1\cdot3\cdot(\dots)\cdot(2n-1)\bigr)\bigl(2\cdot4\cdot(\dots)\cdot 2n\bigr)}{(2\cdot4\cdot(\dots)\cdot2n)}\\ &= 1\cdot3\cdot(\dots)\cdot(2n-1)\frac{\bigl(2\cdot4\cdot(\dots)\cdot 2n\bigr)}{(2\cdot4\cdot(\dots)\cdot2n)}\\ &= 1\cdot3\cdot(\dots)\cdot(2n-1)\left(\vphantom{\frac{a}{a}}1\right)\\ &= 1\cdot3\cdot(\dots)\cdot(2n-1) \end{aligned}
At any rate, this gives us a polynomial expression for ${f(1+h)}$ as
(31)$\displaystyle f(1+h) = \left(1+\sum^{6}_{n=1}\frac{(-1)^{n-1}(2n)!}{(n!2^{n})^{2}}h^{n}\right) + R_{6}(h)$
where ${R_{6}(h)}$ is the “error” term. What does the error term tell us? Precisely how good or bad our polynomial approximates ${f(1+h)}$. That is to say, how ${(1+c_{1}h+\dots+c_{6}h^{6})}$ approximates ${f(1+h)}$.

Question: how do we find the error term?

Exercise 1 [Math.SE]. Using the MacLaurin series for sine and cosine, check that
$\displaystyle\frac{\mathrm{d}\cos(x)}{\mathrm{d}x}=-\sin(x)$ and $\displaystyle\frac{\mathrm{d}\sin(x)}{\mathrm{d}x}=\cos(x)$

Exercise 2. What is the Taylor series for $\ln(x)$ about $x=1$? I.e., what is the MacLaurin series for $\ln(1+h)$?

Exercise 3 [Math.SE]. Using Exercise 2, demonstrate using the MacLaurin series for $\exp(x)$ that $\exp\bigl(\ln(1+x)\bigr)=1+x$. You can work up to $x^{4}$ if you want.

Exercise 4 [Math.SE]. What is the MacLaurin series for the function $1/(1-x)$?

Exercise 5 [Math.SE]. Find the MacLaurin series for $\arctan(x)$ by first taking its derivative, then considering the MacLaurin series for this derivative, and then integrating the MacLaurin series.

Exercise 6 [Math.SE]. Using the MacLaurin series for sine and cosine, plug them into the formula $\sin^{2}(x)+\cos^{2}(x)$, and what do we get?

Exercise 7 [Math.SE] What is the Taylor series for $\ln(\tan(x))-\ln(x)$ about $x=0$?

Exercise 8. Use the MacLaurin series for sine to prove
$\displaystyle\lim_{x\to0}\frac{\sin(x)}{x}=1$.

Exercise 9 [Math.SE]. What is the MacLaurin series for $\displaystyle [\cos(x)]^{\sin(x)}$?

Exercise 10. What is the Taylor series for $f(x)=\sqrt[3]{x}$ about $x=1$? Or if you prefer, find the MacLaurin series for $f(1+h)=\sqrt[3]{1+h}$.

Exercise 11. What is the MacLaurin series for ${\displaystyle\frac{1}{\sqrt{1-x}}}$?