Calc. II, Lab 4: Taylor Polynomials

January 26, 2012

Introduction

In this lab, we will be investigating some functions and their associated Taylor polynomials. We will use Mathematica to compute the Taylor polynomials for three functions. We will look at Taylor polynomials of various degrees and compare the plots of the functions and the Taylor polynomials. We will make conjectures about how good an approximation the Taylor polynomial is. The explorations outlined below are based on 4.4.9 and 4.4.10.

You may work in groups of 2–3.  As a group, you will write a report with your findings.  Your report should have a title and an introductory paragraph stating the purpose of the report and your principal findings.  Then your report should include several paragraphs explaining what you did (procedure) and what you discovered (results).  Finally, your report should include a paragraph with your conjectures and conclusions.  The report should be illustrated with graphs that display your observations.  I would recommend creating one Mathematica notebook for scratch work and one Mathematica notebook for your report.

The report is due at the beginning of lab next Thursday, February 2.  Bring a hard copy of your report to lab.  Also, save the final draft of your report in the Lab4 folder (in the Math212 folder on the M-drive) and include your names in the filename, e.g. if I was turning in a report, I might name it lab04_report_decelles.nb.

Helpful Mathematica Commands

In Section 4.4 of the book, Shahriari gives examples of a few helpful Maple commands for working with Taylor series.  The way Taylor polynomials are implemented in Mathematica is a little different, as explained below.

Suppose we want to find the fifth Taylor polynomials for the function f(x)=(1/((x^2)+1))at x=0.  We use the Series command, as follows:

Series[1/(x^2 + 1), {x, 0, 5}]

(Place your cursor at the end of the Series command and press Shift+Enter to see the output.)  Notice that the output is an expression in x.  The O((x^6)) term is a technical way of specifying the error, which we will not discuss right now.  We are only interested in the polynomial itself, so we use the Normal command to extract the actual polynomial from the output of the Series command, as follows.

Normal[Series[1/(x^2 + 1), {x, 0, 5}]]

(Place your cursor at the end of the Series command and press Shift+Enter to see the output.)  Again, the output is an expression in x.  In Mathematica, expressions are different from functions, so we will have to use an additional command, the Evaluate command, to get Mathematica to plot the Taylor polynomial.  First we name the Taylor polynomial.  Then we will plot it from -2 to 2.

T5 = Normal[Series[1/(x^2 + 1), {x, 0, 5}]]
Plot[Evaluate[T5], {x, -2, 2}]

Go ahead and evaluate those two lines, to see the graph.  To plot the Taylor polynomial along with the original function, evaluate the following command:

Plot[{1/(x^2+1), Evaluate[T5]}, {x, -2, 2}]

To change the y-limits, so that we can see how well the Taylor polynomial approximates the function, use the PlotRange option, as follows:

Plot[{1/(x^2+1), Evaluate[T5]}, {x, -2, 2}, PlotRange->{0, 1.5}]

Advanced Mathematica Commands

For those of you who feel comfortable using more advanced Mathematica commands, a quick way to compute several Taylor polynomials at once is to use the Table command:

TaylorPolys = Table[Normal[Series[1/(x^2 + 1), {x, 0, n}]], {n, 0, 10}]

Since the output of the Table command is a list, we can plot all of these at once in the following way,

Plot[Evaluate[TaylorPolys], {x, -2, 2}, PlotRange->{0,1.5}]

To plot the original function along with the Taylor polynomials, we need to add the original function to the list contained in the variable TaylorPolys, using the Join command.

Plot[Join[{1/(x^2+1)}, Evaluate[TaylorPolys]], {x, -2, 2}, PlotRange->{0,2}]

Explorations

In this lab, you will explore the following three functions:

({{({{f(x)=(e^x)
g(x)=sin(x)
h(x)=(1/(x-1))}})}})

For each of these functions,

Find Taylor polynomials of various degrees for the function at x=0.  For example, you can
find polynomials of degree 3, degree 5, degree 13, even degree 25.  Mathematica will do the work for you.

Using Mathematica, graph the function as well as the Taylor polynomials on the same set of axes.  Choose limits for the x-axis and y-axis to get a good view of both the function and the Taylor polynomials.  (You can use these graphs in your report.  After copy and paste them into your report, double-click on them and use the Drawing Tools to label each curve appropriately.)

Consider the following questions as you do your explorations:

For which values of x do these look like good approximations for the function?

What happens as you increase the degree of the Taylor approximation?  Do the approximations get better?

Can you use the Taylor polynomial as an approximation for more values of x?

Suppose we want to approximate the value of the original function at x=-3.  Can we pick the degree of the Taylor polynomial large enough so that we have a reasonable approximation?  How large of a degree?

Suppose we want to approximate the original function at x=5 or x=-10?  Can we find a Taylor polynomial that would be able to approximate those values?

For which values of x can we easily approximate the function using a Taylor polynomial at x = 0.

Your answers will vary with different functions f(x).