Taylor Series
Many non-polynomial functions can be represented by infinite polynomials.
This post is part of the book Justin Math: Calculus. Suggested citation: Skycak, J. (2019). Taylor Series. In Justin Math: Calculus. https://justinmath.com/taylor-series/
Want to get notified about new posts? Join the mailing list and follow on X/Twitter.
The sum formula for a geometric series is an example of representing a non-polynomial function as an infinite polynomial within a particular range of inputs.
Many other non-polynomial functions can be represented by infinite polynomials called Taylor series. The general formula for the Taylor series of a function $f(x)$, centered about a point $x=c$, is
Just like for the geometric series sum formula, the Taylor series can only be used when it converges. The ratio test is particularly useful for finding the x-values for which the series converges.
For the sake of example, we will compute the Taylor series of several familiar functions: $e^x$, $\sin x$, and $\ln x$. To introduce some variety, we will center each series at a different x-value.
Taylor Series of the Exponential Function
For $f(x)=e^x$, we have $f’(x)=e^x$, $f’^\prime(x)=e^x$, and in general $f^{(n)}(x)=e^x$ for all values of $n$. The Taylor series of $f(x)=e^x$ centered at $x=0$ is then given by
Applying the ratio test, we see that the series converges when
Thus, the series converges for all values of $x$.
Taylor Series of Sine
For $f(x)=\sin x$, we have $f’(x)=\cos x$, $f’^\prime(x)=-\sin x$, $f’’^\prime(x)=-\cos x$, $f^{(4)}(x)=\sin x$, and in general $f^{(2n)}(x)=(-1)^n \sin x$ and $f^{(2n+1)}(x)=(-1)^n \cos x$.
The Taylor series of $f(x)=\sin x$ centered at $x=\pi$ is then given by
Applying the ratio test, we see that the series converges when
Thus, the series converges for all values of $x$.
Taylor Series of Natural Log
For $f(x)=\ln x$, we have $f’(x)=\frac{1}{x}$, $f’^\prime(x)=-\frac{1}{x^2}$, $f’’^\prime(x)=\frac{2}{x^3}$, and in general $f^{(n)}(x)=(-1)^{n-1} \frac{(n-1)!}{x^n}$ for $n>1$. The Taylor series of $f(x)=\ln x$ centered at $x=1$ is then given by
Applying the ratio test, we see that the series converges when
Thus, the series converges for $0<x<2$.
Derivation
To see where the formula for the Taylor series comes from, we start by performing repeated integration on the function $f^{(n+1)}(x)$.
Solving for $f(x)$, we find
Taking the limit as $n \to \infty$, we can express $f$ as the sum of its Taylor series and some remainder term.
For many familiar functions, with $x$ sufficiently close to $c$, it is often the case that the remainder decays to zero:
For example, the remainder decays to zero if $f$ is any polynomial, because differentiating an $\text{n}^\text{th}$ degree polynomial $n+1$ times always yields a result of $0$, and the integral of $0$ is always $0$. (But this is rather trivial since the Taylor series of a polynomial is the polynomial itself.)
More generally, we can place an upper bound on the size of the $\text{n}^\text{th}$ remainder:
Then, since
we must have that
Provided that the $(n+1)^\text{st}$ derivative doesn’t grow large enough to overpower the $(n+1)!$ term in the denominator as $n \to \infty$, the remainder will decay to zero. Then the function will be equal to its Taylor series, provided that the series converges.
Exercises
Compute the Taylor series for the following functions, centered at the given points. Also compute the interval of convergence. (You can view the solution by clicking on the problem.)
$\begin{align*} 1) \hspace{.5cm} &f(x)= \ln (1+x) \\ &\mbox{at } x=0 \end{align*}$
Solution:
$\begin{align*} &\sum\limits_{n=1}^\infty \frac{(-1)^{n+1} }{n}x^n \\ & -1 < x \leq 1 \end{align*}$
$\begin{align*} 2) \hspace{.5cm} &f(x)=\frac{1}{(1+x)^2} \\ &\mbox{at } x=0 \end{align*}$
Solution:
$\begin{align*} &\sum\limits_{n=0}^\infty (-1)^n(1+n) x^n \\ & -1 < x < 1 \end{align*}$
$\begin{align*} 3) \hspace{.5cm} &f(x)=\cos x \\ &\mbox{at } x=0 \end{align*}$
Solution:
$\begin{align*} &\sum\limits_{n=0}^\infty \frac{(-1)^n}{(2n)!} x^{2n} \\ & -\infty < x < \infty \end{align*}$
$\begin{align*} 4) \hspace{.5cm} &f(x)= \cos x \\ &\mbox{at } x=\pi \end{align*}$
Solution:
$\begin{align*} &\sum\limits_{n=0}^\infty \frac{(-1)^{n+1} }{(2n)! } (x-\pi)^{2n} \\ & -\infty < x < \infty \end{align*}$
$\begin{align*} 5) \hspace{.5cm} &f(x)= \arctan x \\ &\mbox{at } x=0 \end{align*}$
Solution:
$\begin{align*} &\sum\limits_{n=0}^\infty \frac{(-1)^n}{2n+1} x^{2n+1} \\ & -1 \leq x \leq 1 \end{align*}$
$\begin{align*} 6) \hspace{.5cm} &f(x)= 2^x \\ &\mbox{at } x=-1 \end{align*}$
Solution:
$\begin{align*} &\sum\limits_{n=0}^\infty \frac{(\ln 2)^n}{(2n)!} (x+1)^n \\ & -\infty < x < \infty \end{align*}$
$\begin{align*} 7) \hspace{.5cm} &f(x)= \frac{1}{x} \\ &\mbox{at } x=2 \end{align*}$
Solution:
$\begin{align*} &\sum\limits_{n=0}^\infty \frac{(-1)^n}{2^{n+1} } (x-2)^n \\ & 0 < x < 4 \end{align*}$
$\begin{align*} 8) \hspace{.5cm} &f(x)= \frac{1}{x} \\ &\mbox{at } x=-10 \end{align*}$
Solution:
$\begin{align*} &\sum\limits_{n=0}^\infty - \frac{1}{10^{n+1} }(x+10)^n \\ & -20 < x < 0 \end{align*}$
This post is part of the book Justin Math: Calculus. Suggested citation: Skycak, J. (2019). Taylor Series. In Justin Math: Calculus. https://justinmath.com/taylor-series/
Want to get notified about new posts? Join the mailing list and follow on X/Twitter.