Finding Taylor Series

Now that we understand a little bit about when series converge, we will turn our attention to finding the series representations of some elementary functions.


Using one series to find another

We already know one series:

\[  
\frac{1}{1-u} = 1+u+u^2 + u^3 +\ldots = \sum_{n=0}^\infty u^n 
 \]

when $  |u| < 1  $ . We can use this series to find series representations of other functions. To begin, we can change the variable by a substitution; suppose that $  u = -t  $ , then


\begin{eqnarray*} 
\frac{1}{1-(-t)} & = & 1 + (-t) + (-t)^2 + (-t)^3 + \ldots \\ 
\frac{1}{1+t} & = & 1 - t + t^2 - t^3 + t^4 + \ldots 
\end{eqnarray*}

This means we have produced the series for the function $ 
\frac{1}{1+t}  $ . This is pretty simple; however, it gets much more interesting if we consider operations such as integration:


\begin{eqnarray*} 
\int_0^x \frac{1}{1+t}~dt & = & \int_0^x (1 - t + t^2 - t^3 + t^4 - 
\ldots)~dt \\ 
\ln(1+x) & = & x - \frac{x^2}{2} + \frac{x^3}{3} - \frac{x^4}{4} + 
\ldots = \sum_{n=1}^\infty (-1)^{n+1}\frac{x^n}{n} 
\end{eqnarray*}

Here we have produced a series representation for a new function. The demonstration below will show you how the Taylor polynomials provide a better and better approximation as the degree of the polynomial increases.

In fact, this demonstrates the use of Taylor series well: the function we have found $  \ln(1+x)  $ is a fairly complicated function. For instance, it is difficult to evaluate without some kind of computational aid. However, the right hand side gives an expression which is relatively easy to calculate using the elementary operations of addition and multiplication. This was, in fact, the original use of Taylor series. We will find other uses as well.

For the series

\[ 
\ln(1+x) = x - \frac{x^2}{2} + \frac{x^3}{3} - \frac{x^4}{4} + \ldots 
 \]

we again need to be careful when considering the convergence properties. We obtained this by starting with the geometric series which only converged when $  |u| < 1  $ so we certainly cannot expect the series for $  \ln(1+x)  $ to converge when $  |x| 
> 1  $ .

Notice that when $  x = -1  $ , the left hand side is $ 
\ln(0)  $ which is not defined. At the same time, the right hand side is

\[ 
-(1+\frac 12 + \frac 13 + \frac 14 + \ldots) 
 \]

which is minus the harmonic series. Of course, we have seen that the harmonic series diverges so we cannot have the series converge when $  x = -1  $ .

However, when $  x = 1  $ , we have

\[ 
\ln(2) = 1-\frac 12 + \frac 13 - \frac 14 + \ldots 
 \]

This series is the alternating harmonic series and we have seen that it converges. This relationship shows us that, remarkably, the alternating harmonic series converges to $  \ln(2)  $ . This can be explicitly seen in the demonstration below.


Finding the coefficients directly from the function

Suppose we have a function which we want to write as

\[ 
f(x) = a_0 + a_1x + a_2x^2 + a_3x^3 + \ldots = \sum_{n=0}^\infty 
a_nx^n 
 \]

We can use information about the function to directly determine the coefficients. To determine $  a_0  $ , let's evaluate the function and the series at $  x = 0  $ .

\[ 
f(0) = a_0 + a_10 + a_20^2 + a_30^3 + \ldots = a_0 
 \]

This shows us that the first coefficient $  a_0 = f(0)  $ . In the same way, we can find the rest of the coefficients by differentiating:

\[ 
\begin{array}{rcl} 
f^\prime(x) & = & a_1 + 2a_2x + 3a_3x^2 + \ldots + na_nx^{n-1} +\ldots\\ \\ 
f{^\prime\prime}(x) & = &2a_2 + 2\cdot 3a_3x + \ldots + (n-1)na_nx^{n-2} 
+\ldots\\ \\ 
f{^\prime\prime\prime}(x) & = & 2\cdot 3a_3 + \ldots + 
(n-2)(n-1)na_nx^{n-3} +\ldots\\ \\ 
f^{(n)}(x) & = & 1\cdot 2\cdot 3\cdot 4\ldots n a_n + \ldots 
\end{array} 
 \]

Now if we evaluate at $  x = 0  $ , we have

\[ 
\begin{array}{ll} 
f^\prime(0)  = a_1,  & a_1 = f^\prime(0) \\ \\ 
f^{\prime\prime}(0)  =  2a_2,  & a_2 = \frac{f^{\prime\prime}(0)}{2} \\ \\ 
f^{\prime\prime\prime}(0)  =  2\cdot 3 a_3,  \hspace{.2in} 
& a_3 = \frac{f^{\prime\prime}(0)}{2\cdot 3} \\ \\ 
f^{(n)}(0)  =  n!a_n,  & a_n = \frac{f^{(n)}(0)}{n!} 
\end{array} 
 \]

This means that if we can compute all the derivatives of the function $  f(x)  $ , then we know the coefficients of the Taylor series as well.

Examples:

  1. $  f(x) = e^x  $

    The beautiful fact about this function is that all its derivative are equal to $  e^x  $ as well. In particular, $ 
f^{(n)}(x) = e^x  $ so that $  f^{(n)}(0) = 1 $ . This means that the coeficients of the Taylor series are given by

    \[ 
a_n = \frac{f^{(n)}(0)}{n!} = \frac{1}{n!} 
 \]

    and so the Taylor series is given by

    \[ 
1 + x + \frac{x^2}2 + \frac{x^3}{6} + \frac{x^4}{24} + \ldots + 
\frac{x^n}{n!} + \ldots = \sum_{n=0}^\infty \frac{x^n}{n!} 
 \]

    Now we will tell you two facts that are important here: first, this series converges for all values of $  x  $ . In fact, you have already seen this for $  x = 1  $ when we talked about convergence. Here is the demonstration which shows you the first few terms of the series:

    Since this series converges for all values of x, it actually defines a function of x given by evaluating the series. The second important fact is that the function defined by the series is in fact equal to $  e^x  $ ; that is,

    \[ e^x=1+x+\frac{x^2}2 + \frac{x^3}{6} + \ldots = \sum_{n=0}^\infty 
\frac{x^n}{n!} 
 \]

    It would require a bit of work to show you why this is true, but it's just enough for you to know this fact and that it is remarkable. You see, the Taylor series that we computed was based on the information about the function $  e^x  $ at a single point $  x = 0  $ . Since the function is equal to its Taylor series at every point, that implies that the function $ e^x  $ is completely determined by what happens right around $  x = 0 
 $ . In other words, the value of the function at $  x = 
1,000,000  $ is determined by the behaviour of the function around $  x = 0  $ .

    This is really quite incredible when you think about. In fact, "most" functions are not like this. If you were to just draw a random graph, there would probably be no relationship between what the function looks like at $  x  = 1  $ and the behaviour around $  x = 0  $ . This means that $  e^x  $ is a very special function indeed and so we will give it a special name:

    If a function $  f(x)  $ agrees with its Taylor polynomial on a region $  (-a,a)  $ , we say that f is analytic on this region.

    Basically, most of the functions we have considered in this class---polynomials, exponentials, and trigonometric functions--- are analytic meaning that they agree with their Taylor series on some region. It is beyond the scope of this course to explain why this is, but the underlying reason is that they arise as solutions to simple differential equations. For instance, $  e^x  $ solves the differential equation $  \frac{dy}{dx} = y  $ and $  \sin(x) 
 $ solves $  \frac{d^2y}{dx^2} = -y  $

  2. $  f(x) = \sin x  $

    We will determine the Taylor series for this function by finding its derivatives: notice that

    \[ 
\begin{array}{c} 
f(x) = \sin x \\ 
f^\prime(x) = \cos x \\ 
f^{\prime\prime}(x) = -\sin x \\ 
f^{\prime\prime\prime}(x) = -\cos x \\ 
f^{(4)}(x) = \sin x 
\end{array} 
 \]

    and then the cycle repeats. This means that $  f(0) = 0, 
f^\prime(0) = 1, f^{\prime\prime}(0) = 0, f^{\prime\prime\prime}(0) = 
-1 $ and then the pattern repeats. In other words,

    \[ 
a_0 = 0, a_1 = 1, a_2 = 0, a_3 = -\frac {1}{3!}, a_4 = 0, 
a_5=\frac{1}{5!},\ldots 
 \]

    Now it is a fact that $  \sin x  $ is analytic for all x so that we have

    \[ 
\sin x = x - \frac{x^3}{3!} + \frac{x^5}{5!} - \frac{x^7}{7!} + \ldots 
=\sum_{n=0}^\infty (-1)^n \frac{x^{2n+1}}{(2n+1)!} 
 \]

  3. To determine the Taylor series for $  \cos x  $ , we can simply differentiate the series for $  \sin x  $ .

    
\begin{eqnarray*} 
\cos x& = & \frac{d}{dx} \sin x \\ 
& = & \frac{d}{dx} (x-\frac{x^3}{3!} + \frac{x^5}{5!} - \frac{x^7}{7!} 
+\ldots) \\ 
& = & 1 - \frac{x^2}{2} + \frac{x^4}{4} - \frac{x^6}{6!} + \ldots = 
\sum_{n=0}^\infty (-1)^n \frac{x^{2n}}{(2n)!} 
\end{eqnarray*}