# Taylor series

Suppose that $f$ is differentiable infinitely many times on an open interval containing $a$. Then $$\sum_{n=0}^\infty\frac{f^{(n)}(a)}{n!}(x-a)^n=f(a)+\frac{f'(a)}{1!}(x-a)+\frac{f^{\prime\prime}(a)}{2!}(x-a)^2+\frac{f^{\prime\prime\prime}(a)}{3!}(x-a)^3+\cdots$$ is called the Taylor series of $f$ centered at $a$. A Taylor series centered at 0 is called a Maclaurin series.

Example. Find the Maclaurin series of $f(x)=e^x$ and its radius of convergence $R$.

Solution. The Maclaurin series is $\sum_{n=0}^\infty\frac{f^{(n)}(0)}{n!}x^n=\sum_{n=0}^\infty\frac{x^n}{n!}$. By the ratio test $$\lim_{n\to\infty}\left|\frac{a_{n+1}}{a_n}\right|=\lim_{n\to\infty}\frac{|x|}{n+1}=0<1$$ for all $x$ so the series converges for all $x$ i.e. the radius of convergence is $R=\infty$.

The following theorem tells when a function $f(x)$ can be represented by its Taylor series. Recall that $f(x)=T_n(x)+R_n(x)$ where $T_n(x)$ is the $n$-th degree Taylor polynomial of $f$ at $a$ and $R_n(x)=\frac{f^{(n+1)}(\xi)}{(n+1)!}(x-a)^{n+1}$ where $a<\xi<x$ or $x<\xi<a$.

Theorem. $f=\sum_{n=0}^\infty\frac{f^{(n)}(a)}{n!}(x-a)^n$ for $|x-a|<R$ if and only if $\lim_{n\to\infty}R_n(x)=0$ for $|x-a|<R$.

Since $\sum_{n=0}^\infty\frac{x^n}{n!}$ converges for all $x$, $$\label{eq:explim}\lim_{n\to\infty}\frac{x^n}{n!}=0$$ Now we show that $$\label{eq:expx}e^x=\sum_{n=0}^\infty\frac{x^n}{n!}$$ for all $x$. $R_n(x)=\frac{e^\xi}{(n+1)!}x^{n+1}$ where $0<\xi<x$ or $x<\xi<0$. If $0<\xi<x$ then $0<R_n(x)<\frac{e^x}{(n+1)!}x^{n+1}\to 0$ as $n\to\infty$ by \eqref{eq:explim}. If $x<\xi<0$ then $0\leq |R_n(x)|<\frac{|x|^{n+1}}{(n+1)!}\to 0$ as $n\to\infty$ again by \eqref{eq:explim}. This completes the proof of \eqref{eq:expx}. For $x=1$ we have a definition of the Euler number $e$ in terms of a series as $$\label{eq:eulernum}e=\sum_{n=0}^\infty\frac{1}{n!}=1+\frac{1}{1!}+\frac{1}{2!}+\frac{1}{3!}+\cdots$$

Example. Find the Taylor series of $f(x)=e^x$ at $a=2$.

Solution. By the same manner, one can show that $$e^x=\sum_{n=0}^\infty\frac{e^2}{n!}(x-2)^n$$ for all $x$.

Example. Find the Maclaurin series of $\sin x$ and show that it represents $\sin x$ for all $x$.

Solution. The Maclaurin series is $\sum_{n=0}^\infty\frac{x^{2n+1}}{(2n+1)!}$ and by the ratio test one can show that it converges for all $x$. Since $|f^{(n+1)}(\xi)|\leq 1$, $0\leq |R_n(x)|\leq\frac{|x|^{n+1}}{(n+1)!}\to 0$ as $n\to\infty$. Hence, $$\label{eq:sinx}\sin x=\sum_{n=0}^\infty\frac{x^{2n+1}}{(2n+1)!}$$ for all $x$.

Similarly one can also show that $$\label{eq:cosx}\cos x=\sum_{n=0}^\infty\frac{x^{2n}}{(2n)!}$$ for all $x$.

Euler’s Formula

If $x$ is replaced by $ix$ in \eqref{eq:expx}, we obtain \begin{align*}e^{ix}&=\sum_{n=0}^\infty\frac{(ix)^n}{n!}\\&=\sum_{n=0}^\infty\frac{x^{2n}}{(2n)!}+i\sum_{n=0}^\infty\frac{x^{2n+1}}{(2n+1)!}\\&=\cos x+i\sin x\end{align*}$$\label{eq:eulerformula}e^{ix}=\cos x+i\sin x$$ is called the Euler’s Formula and it represents the point on the unit circle centered at the origin corresponding to the angle $x$. The formula in \eqref{eq:eulerformula} comes in handy in so many places of mathematics from trigonometry, calculus, differential equations to abstract algebra, topology, geometry to name a few. It is also a useful tool in physics on many occasions. For example, one can derive the sine sum and the cosine sum formulas using \eqref{eq:eulerformula}: $e^{i(\theta_1+\theta_2)}=\cos(\theta_1+\theta_2)+i\sin(\theta_1+\theta_2)$.  On the other hand, \begin{align*}e^{i(\theta_1+\theta_2)}&=e^{i\theta_1}e^{i\theta_2}\\&=(\cos\theta_1+i\sin\theta_1)(\cos\theta_2+i\sin\theta_2)\\&=(\cos\theta_1\cos\theta_2-\sin\theta_1\sin\theta_2)+i(\cos\theta_1\sin\theta_2+\sin\theta_1\cos\theta_2)\end{align*} Hence we obtain the sine and the cosine sum formulas \begin{align*}\sin(\theta_1+\theta_2)&=\sin\theta_1\cos\theta_2+\cos\theta_1\sin\theta_2\\\cos(\theta_1+\theta_2)&=\cos\theta_1\cos\theta_2-\sin\theta_1\sin\theta_2\end{align*} When $\theta=\pi$, we obtain the so-called the Euler’s identity $$\label{eq:euleridentity}e^{\pi i}+1=0$$ which contains the most fundamental constants of mathematics $\pi$, $e$, $i$, 0, and 1.

The Binomial Series

Let us find the Maclaurin series of $f(x)=(1+x)^k$ where $k$ is any real number. First, we find $$f^{(n)}(x)=k(k-1)\cdots(k-n+1)(1+x)^{k-n}$$ and so $$f^{(n)}(0)=k(k-1)\cdots(k-n+1)$$ Hence the Maclaurin series is given by $$\sum_{n=0}^\infty\frac{k(k-1)\cdots(k-n+1)}{n!}x^n$$ The coefficients $\frac{k(k-1)\cdots(k-n+1)}{n!}$, $n=0,1,2,\cdots$ are denoted by ${}_n\mathrm{C}_k$ or $\begin{pmatrix}k\\n\end{pmatrix}$ and are called binomial coefficients. $$\lim_{n\to\infty}\left|\frac{a_{n+1}}{a_n}\right|=\left|\frac{k-n}{n+1}\right||x|=\lim_{n\to\infty} |x|$$ So by the ratio test if $|x|<1$ then the series converges and if $|x|>1$ then it diverges. Furthermore it can be shown (we omit the proof) that $$\label{eq:binomialseries}(1+x)^k=\sum_{n=0}^\infty\frac{k(k-1)\cdots(k-n+1)}{n!}x^n$$ for $|x|<1$. The series in \eqref{eq:binomialseries} is called the binomial series.

Example. FInd the Maclaurin series of $f(x)=\frac{1}{\sqrt{4-x}}$.

Solution. \begin{align*}\frac{1}{\sqrt{4-x}}&=\frac{1}{2}\frac{1}{\sqrt{1-\frac{x}{4}}}\\&=\frac{1}{2}\left(1-\frac{x}{4}\right)^{-\frac{1}{2}}\\&=\frac{1}{2}\sum_{n=0}^\infty\begin{pmatrix}-\frac{1}{2}\\n\end{pmatrix}\left(-\frac{x}{4}\right)^n\\&=\frac{1}{2}\left\{1+\left(-\frac{1}{2}\right)\left(-\frac{x}{4}\right)+\frac{\left(-\frac{1}{2}\right)\left(-\frac{3}{2}\right)}{2!}\left(-\frac{x}{4}\right)^2+\frac{\left(-\frac{1}{2}\right)\left(-\frac{3}{2}\right)\left(-\frac{5}{2}\right)}{3!}\left(-\frac{x}{4}\right)^3+\cdots\\+\frac{\left(-\frac{1}{2}\right)\left(-\frac{3}{2}\right)\left(-\frac{5}{2}\right)\cdots\left(-\frac{2n-1}{2}\right)}{n!}\left(-\frac{x}{4}\right)^n+\cdots\right\}\\&=\frac{1}{2}\left\{1+\frac{x}{8}+\frac{1\cdot 3}{2!8^2}x^2+\frac{1\cdot\cdot 5}{3!8^3}x^3+\cdots+\frac{1\cdot 3\cdot 5\cdots(2n-1)}{n!8^n}x^n+\cdots\right\}\end{align*} This series converges if $\left|-\frac{x}{4}\right|<1$ i.e. $|x|<4$. The radius of convergence is 4.

Working with Taylor Series

Example. Use Taylor series to evaluate $\lim_{x\to 0}\frac{x^2+2\cos x-2}{3x^4}$.

Solution. \begin{align*}\lim_{x\to 0}\frac{x^2+2\cos x-2}{3x^4}&=\lim_{x\to 0}\frac{x^2+2\left(1-\frac{x^2}{2!}+\frac{x^4}{4!}-\frac{x^6}{6!}+\cdots\right)-2}{3x^4}\\&=\lim_{x\to 0}\frac{2\left(\frac{x^4}{4!}-\frac{x^6}{6!}+\cdots\right)}{3x^4}\\&=\frac{2}{4!3}=\frac{1}{36}\end{align*}

Remark. The above limit can be also calculated using the L’Hôpital’s rule as it is an indeterminate form of type $\frac{0}{0}$.

Example. Approximate $\int_0^1 e^{-x^2}dx$ with an error no greater than $5\times 10^{-4}$.

Solution. \begin{align*}\int_0^1 e^{-x^2}dx&=\int_0^1\left(1-x^2+\frac{x^4}{2!}-\frac{x^6}{3!}+\cdots+\frac{(-1)^nx^{2n}}{n!}+\cdots\right)dx\\&=\left[\left(x-\frac{x^3}{3}+\frac{x^5}{2!5}-\frac{x^7}{3!7}+\cdots+\frac{(-1)^nx^{2n+1}}{n!(2n+1)}+\cdots\right)\right]_0^1\\&=1-\frac{1}{3}+\frac{1}{2!5}-\frac{1}{3!7}+\cdots+\frac{(-1)^n}{n!(2n+1)}+\cdots\end{align*} Recall that for an alternating series $\sum_{n=0}^\infty(-1)^n a_n$, $|R_n|\leq a_{n+1}$. For $n=4$, $|R_4|\leq a_5=\frac{1}{5!11}=7.6\times 10^{-3}>5\times 10^{-4}$. For $n=5$, $|R_5|\leq a_6=\frac{1}{6!13}=1.07\times 10^{-4}<5\times 10^{-4}$. Thus the error is less than $5\times 10^{-4}$ if $n\geq 5$. The approximation with $n=5$ is given by \begin{align*}\int_0^1 e^{-x^2}dx&\approx 1-\frac{1}{3}+\frac{1}{2!5}-\frac{1}{3!7}+\frac{1}{5!11}\\&\approx 0.747\end{align*}