next up previous
Next: About this document ... Up: Labs and Projects for Previous: Labs and Projects for

Subsections


Taylor Series

Mathematical Background

So far, you have considered series whose terms were constants; for example the geometric series

\begin{displaymath}
{1\over 2}+{1\over 4}+{1\over 8}+\cdots\end{displaymath}

We can also consider series whose terms are functions. The most important such type of series is the power series

\begin{displaymath}
f(x) = \sum_{k=0}^\infty a_k x^k\end{displaymath}

or, more generally,

\begin{displaymath}
f(x) = \sum_{k=0}^\infty a_k (x-c)^k\,.\end{displaymath}

The domain of f(x) is the set of x such that the series converges. This set will be an interval about x=c, called the interval of convergence. Since power series define functions, we can ask if a given function can be represented as a power series. In many cases the answer is yes. To see which power series provides the ``best fit'' to a given function F(x), we choose a point c in the domain of F. Then we require that at c, the power series and the function agree at c; and that all derivatives of the power series equal the corresponding derivatives of F(x). The result is the power series

\begin{displaymath}
\sum_{k=0}^\infty {F^{(k)}(c)\over k!} (x-c)^k\,, \end{displaymath}

which is called the Taylor series for F(x) at c.

The Taylor series for F(x) at c is not necessarily equal to F(x) on the series's interval of convergence. (See the text, p. 555, for a counterexample.) However, if F(x) can be represented by a power series at c, the Taylor series must be the power series that does so. In practice the Taylor series does converge to the function for most functions of interest, so that the Taylor series for a function is an excellent way to work that function.

You have seen that a good strategy for working with infinite sums is to use a partial sum as an approximation, and to try to get a bound on the size of the remainder. This leads to the question of whether one can approximate a given function F(x) by using a partial sum of its Taylor series, a question which is answered by Taylor's theorem.

Theorem If f(x) and all its derivatives exist in an open interval containing c, then for each x in that interval, we may write

f(x) = Tn(x)+Rn(x)

where

\begin{displaymath}
T_n(x) = \sum_{k=0}^n {F^{(k)}(c)\over k!}(x-c)^k \end{displaymath}

is the nth-degree Taylor polynomial of f(x) at c; and Rn(x), the remainder, satisfies

\begin{displaymath}
R_n(x) = {f^{(n+1)}(z_n)\over (n+1)!}(x-c)^{n+1} \end{displaymath}

for some zn between c and x.

Observe that zn depends on x; hence Rn(x) is not a term of a Taylor polynomial.

Maple Commands for Taylor Series

Maple contains a built in function, taylor, for generating Taylor series. For example, the following maple command generates the first four terms of the Taylor series for the exponential function about x=0.5.

>taylor(exp(x),x=0.5,4);

Note the O((x-0.5)4) term at the end. This term represents the remainder function. The third argument of the taylor command corresponds to the order of the remainder term, not the degree of the Taylor polynomial printed out. Also, note that the presence of the remainder term prevents the output of the taylor command from being plotted or manipulated algebraically.

To overcome this obstacle, the CalcP package contains a slightly different command, Taylor (with a capital T). The output of the Taylor command is a polynomial that can be used in other expressions just like any other polynomial:

>with(CalcP):
>Taylor(exp(x),x=0.5,4);

>plot(",x=0..1);

Note that the third argument gives the degree of the Taylor polynomial output (unlike the first command, which gives the degree of the first term omitted).

For this lab, you will probably find the command Taylor to be more useful than the command taylor. We mention the first command because it is a standard Maple command.

A second useful command in the CalcP package is TayPlot. This command generates graphs of a function and several of its Taylor polynomials on the same plot.

>TayPlot(cos(x),x=0,{2,4,6},x=-Pi..Pi);

Accuracy and Tolerance

To measure how well a Taylor Polynomial approximates the function over a specified interval [c,d], we define the tolerance Tol of Pn(x,a) to be the maximum of

\begin{displaymath}
\mid f(x)- P_n(x,a) \mid \end{displaymath}

over the interval [c,d]. You can actually see how the error of a Taylor polynomial varies over an interval with a Maple command like

  > plot(abs(sin(x)-Taylor(sin(x),x=0,3)),x=-1..1);

For this example, the tolerance, Tol, is about 0.008, which you can find out by looking at the graph.

Now suppose you were asked to determine the order required so that the Taylor polynomial approximation to $\sin(x)$ had a tolerance of 0.005 on the interval [-1,1]. One simple method for doing this graphically is shown below.

  > plot(abs(sin(x)-Taylor(sin(x),x=0,3)),x=-1..1,y=0..0.005);

If you look at the plot, you see that the curve goes out of the plot on the top of the window. This means that the tolerance is not satisfied. If the order is increased to 5, as in the following example, then the curve goes out of the plot on the sides, meaning that the tolerance is satisfied.

  > plot(abs(sin(x)-Taylor(sin(x),x=0,5)),x=-1..1,y=0..0.005);

So, by looking at this plot, you can conclude that a Taylor polynomial of degree five would approximate the function $f(x) = \sin x$ for any point in the interval $-1 \leq x \leq 1$ to two decimal point accuracy.

Suppose that you were asked to check that this is true for any point in that interval, say x = 1 using the error bound. You would need to show that $\sin (1)$ lies between two values that agree to "at least" two decimal places. This can be done by solving the inequality $\displaystyle \vert sin(1) - T_5(1)\vert \leq \vert\frac{f^{(n+1)}(z_n)}{(n+1)!}(x-c)^{(n+1)}\vert$ for $\sin (1)$. (In this example, n=5, c=0, x=1, and T5(1) is the fifth degree Taylor polynomial approximation to $\sin x$ evaluated at x = 1.) The term on the right hand side of this inequality, the Taylor remainder term, needs to be maximized so that we know what the largest possible error would be. How do you maximize any quantity? You find its derivative, set it equal to zero to find critical values, and then test the quantity that you want to maximize at the critical values and at the endpoints of the interval. (recall that zn lies between x and c, x being the value that you are trying to approximate the function at and c being the value that the Taylor series is expanded about) The zn that yeilds the largest answer in absolute max/min test will be the value that should be substituted into the (n+1)st derivative of f.

So for this example, to maximize the product $\displaystyle \vert f^{(n+1)}(z_n)\frac{x^6}{6!}\vert$, we can maximize g(z) = |f(n+1)(z)| with respect to z over the interval $0 \leq z \leq 1$ by applying the absolute max/min test to g(z) and we would have to substitute our only x value, x=1, into $\displaystyle \frac{x^6}{6!}$.

The following maple commands show the procedure in verifying the error bound.

  > f := x -> sin(x);
> g := z -> (D@@6)(f)(z);
> a := diff(g(z),z);
> b := fsolve(a = 0,z);

Notice that the critical value lies outside the interval in question, so we only need to evaluate f(6)(z) = g(z) = -sin z for the endpoints, z=0 and z=1.

  > g(0);
> evalf(g(1));

So, the maximum in absolute value would be 0.8414709848 and this is the z that we can substitute into $-\sin z$.

Solution: $\displaystyle \vert\sin(1) - 0.8416666667\vert \leq \vert(0.8414709848)\frac{1^6}{6!}\vert$

$\displaystyle \vert\sin(1) - 0.8416666667\vert \leq \frac{0.8414709848}{720}$

$\displaystyle \vert\sin(1) - 0.8416666667\vert \leq 0.001167809701$

$-0.00116780970 \leq \sin(1) - 0.8416666667 \leq 0.00116780970$

$0.8403022751 \leq \sin(1) \leq 0.8426396945$

Note that this means that $\sin (1)$ is accurate to three decimal places. Remember, that you were guaranteed accuracy to at least two decimal places.

Exercises

1.
For each of the following functions, give the fifth-order Taylor Polynomial at the point indicated. Then plot the Taylor Polynomial and the function on the same graph, using an interval of length 6 centered at the given point. Label the graph to show which graph is the function and which is the Taylor Polynomial.
(a)
$\sqrt{1+x}$ about x = 0
(b)
$\ln{x^3-1}$ about x=1
(c)
x6 - 4x3 +2 about x=2
(d)
$x\sin x$ about x=-1
2.
Find the 6th degree Taylor polynomial of the function $f(x) = \cos x$ about x=1. Find the Taylor polynomial for $(x - 1)\cos x$ about x = 1 and explain how this is related to the Taylor polynomial of $\cos x$ about x=1.
3.
Find the degree of the Taylor polynomial of $\displaystyle f(x) = \frac{\sin (x)}{e^x} $ about x=0 that will give an error no greater than 0.05 over the interval $0 \leq x \leq \frac{\pi}{2}$. To do this you can plot the absolute value of the difference between the function and the Taylor Polynomial. Verify that this error bound holds for the point $x = \frac{\pi}{2}$ in the given interval. HINT : Use the nth degree Taylor polynomial, for the n that you find, to approximate $f(\frac{\pi}{2})$ accurate to one decimal place. Then use the error term for this Taylor polynomial to show that $\vert f(\frac{\pi}{2})-T_n(\frac{\pi}{2})\vert \leq 0.05$. That is, find the value z between 0 and $\frac{\pi}{2}$ such that the error term is maximized (You will need to recall the absolute max/min test).

4.
Consider the power series $2 - \frac{2}{3}x + \frac{2}{9}x^2 - \frac{2}{27}x^3 + \cdots$. What rational function does this power series represent? Plot the function along with the Taylor polynomial of 5th,6th, and 7th degree about x=0 over the following intervals: [0,1], [0,2], [0,3], [0,4]. Describe what happens to the Taylor approximation over larger intervals for higher degree polynomials.

next up previous
Next: About this document ... Up: Labs and Projects for Previous: Labs and Projects for

Christine M Palmer
1/30/1998