\(MATH\ 257\ Calculus\ III				Week\ of\ April\ 21, \ 
        2003\)
Lab 4 :  Taylor Series
Name 1
Name 2
Section:

I.  Laboratory Objectives
	Use Mathematica to explore  Taylor Series

II.  Formatting and Syntax Information

Series[f, {x, a, n}] 	This generates a Taylor series 
					expansion for f about the point 
					x = a up to the term  (((x - a))^n)
	Normal[expression]		Converts a Taylor series to a 
					Taylor Polynomial by truncating
					the higher order terms

Taylor Series

Think of the Taylor Series of a function f(x) as being a way of getting a different formula for f(x).  

For example, we do NOT have a nice formula for Sin[x], do we?  We always have to rely on our calculator to compute things like Sin[.5].  Taylor Series give us a way of trying to find a formula for things like Sin[x].  

The general form for a Taylor Series about the point x = a:

f(x) = (∑_(n = 0)^∞)(((f^((n)))(a))/(n!))(((x - a))^n)

This is just a Power Series whose coefficiants are given by (Subscript[c, n]) =  (((f^((n)))(a))/(n!)).
Luckily, Mathematica will compute this formula for us, so we don't have to!  (But you wil need to know this for your regular class tests and such...)

A Taylor Polynomial of degree k is the truncated Taylor Series of that degree.  A Taylor Polynomial is a finite polynomial.  We use Taylor polynomials because it's usually too messy to deal with the complete Taylor Series.

Thus the Taylor Polynomial of degree k is 					(∑_(n = 0)^K)(((f^((n)))(a))/(n!))(((x - a))^n)

We will use the command Series to create a Taylor Series expansion of f(x) about  x = a.  
Series[f, {x, a, n}] generates a power series expansion for f about the point x = a to order (((x - a))^n).  In other words, it gives is the Taylor polynomial of degree n.

To begin, let f(x) = ln(x).

Clear[f]

f[x_] := Log[x]

Let's now create the 10th degree Taylor polynomial of f(x)=ln(x) about x = 1.  First, create a Taylor Series called "taylseries".  The syntax Series[f[x], {x, 1, 10}] will give us the first 10 powers of the infinite polynomial plus the term O(([x - (Subscript[x, 0])])^11)which indicated the complete Taylor Series continues on past the 10th degree Taylor polynomial.

tayseries = Series[f[x], {x, 1, 10}]

Normal[series] truncates the power series and converts it to a normal expression for the Taylor Polynomial.   Notice the  +O[x - 1]^11  part.  This is meant to symbollically represent all the higher ordered terms in the Taylor Series in Mathematica.  Note: this is a complicated, different data structure in Mathematica than a regular function.  In order to turn it into an everyday function (so we can graph it and such), we need to use the Normal[] command:

taypoly10[x_] = Normal[taylseries]

From this work we should be able to determine the general form of the Taylor Series for ln(x) about the point x = 1. The series is alternating, it has powers of (x-1) in every term, and the denomenator of coefficient of (((x - 1))^n) is just n.  So we get the infinite Taylor Series:

			\(ln \((x)\) = \ ∑\+\(n = 1\)\%∞\(\(\((\(-1\))\)\^\(n - 1\)\) \((x - 1)\)\^n\)\/n\)

We need to find the radius of convergence of this series.  We  could do this by hand, but it's pretty swank to get Mathematica to do it for us!  
In preparation for using the Ratio Test, let's define the nth term of the series (Subscript[a, n])
(This should look familiar from the last lab.)

\(a[n_, x_] = Abs[x - 1]\^n\/n\)

Now we can form the ratio of the absolute value of ((Subscript[a, n + 1])/(Subscript[a, n ]))giving it the name "ratio."

ratio = a[n + 1, x]/a[n, x]

Next take the limit of this ratio as n-> ∞.

Limit[ratio, n -> ∞]

The series will converge when the answer is less than 1.  To solve the inequality
 |x - 1| < 1, we must load the package "Inequality Solve" in the Algebra package.  This is done below.

<< Algebra`InequalitySolve`

To solve the inequality we use the syntax below:

InequalitySolve[Abs[-1 + x] < 1, x]

So now we know that \(ln \((x)\) = \ ∑\+\(n = 1\)\%∞\(\(\((\(-1\))\)\^\(n - 1\)\) \((x - 1)\)\^n\)\/n\) is a convergent Taylor Series expansion on the interval 0 < x < 2.  We DON'T know what is happening at the end points, at x = 0 and at x = 2.  You'd need to check these endpoints separately.

To see what all this means visually, we will plot both the natural log function and the Taylor Polynomial of degree 10 on the interval .01 < x < 3.  You should be able to see that close to the center (x = 1) the two graphs are nearly identical and that they continue to be similar throughout the interval of convergence.  Outside of the interval of convergence the graphs look dissimilar.  The PlotStyle command sets helps to differentiate between the curves: the natural log function is plotted thicher than normal using "Thickness" and the Taylor Polynomial is plotted using a dashed line using "Dashing."

Plot[{f[x], taypoly10[x]}, {x, 0.01, 3}, 
      PlotStyle -> {{Thickness[ .01]}, {Dashing[{ .02,  .02}]}}]

IV.  Problems to Solve

Question 1 Now analyze some data points along the two curves represented by 
	Log[x]  and  taypoly10[x] (You HAVE to have evaluated taypoly10 above to use it here!)

By evaluating data points in these functions you are testing out the Taylor Polynomial of degree 10 to see how accurate it is against the function ln(x).  
a.  Evaluate both    Log[x] and  taypoly10[x] for the following values of x:
	x = 1/4
	x = 1/2
	x = 3/4
	x = 1
	x = 5/4
	x = 3/2
	x = 2
Tip:  You can enter a list of values into a function, like Log[{1/4, 1/2, 3/4}] and so on.  You can also use the TableForm[ ] command to make your work look neat.

b.  Where is the Taylor Polynomial closest to the value of the natural log function?

Question 2 a.   Now it's your turn to try creating a Taylor Polynomial.  Find the 8th degree Taylor Polynomial for Sin[x] about a =(π/4).  Follow the steps above to first create the Taylor Series and then truncate it using the Normal command.

b.  In preparation for using the Ratio Test, define the nth term of the series (Subscript[a, n]) using the  model of the previous problem.

a[n_, x_]=

c.  Now form the ratio of the absolute value of ((Subscript[a, n + 1])/(Subscript[a, n ]))giving it the name "ratio."

d.  Finally you're ready to take the limit of the ratio.  You'll find that the ratio still includes a factorial term in the numerator and denominator.  In order to take the limit you'll need a simplified version of "ratio" which will cancel the factorials.  Mathematica does this in a roundabout way, so I'll give you the syntax:

Limit[FullSimplify[ratio],  
      n -> ∞]

e.  Explain what this answer to Ratio Test means in a complete sentence.  Be sure write what the interval of convergence is for this Taylor Series.

f.  Finally,  plot the two functions, f[x] = Sin[x] and your 8th degree Taylor Polynomial using a thick solid curve for Sin[x] and a thin dashing curve for the Taylor Polynomial.  Plot them on the x interval [-2π, 2π]. Does this plot confirm what you think the interval of convergence is?  Explain.

Question 3 Recall that the function y=(e^(-(x^2))) has no closed-form antiderivative.  Mathematica has ways of dealing with antiderivatives of this function.  To see this, execute the following:

(2/(Sqrt[π])) (∫_0^x) (E^(-(t^2))) \[DifferentialD]t

You should get the function Erf[x] back.  This is a special function that symbolically represents the antiderivative of (e^(-(x^2))).  Even though Erf[x] is a tricky function, it is easy to approximate it with Taylor polynomials because we can easily take its derivatives!

(a) Why is it easier to find derivatives of Erf[x] than to find values of Erf[x]?  If you don't know, then try asking Mathematica to calculate a few derivatives of Erf[x];  it might jog your memory.

(b) Compute some Taylor polynomials of Erf[x] centered at x=0.  Make sure you do a few big ones, like 10 or 20 terms.  What is the power series for Erf[x] written in summation notation?  (Hint:  Factor out the (2/(Sqrt[π]))  and write it as (2/(Sqrt[π])) (∑_(n = 0)^∞) 
          STUFF.  Make sure to think about factorials.)

(c) Make a NICE plot of Erf[x] and some (at least 3) of your Taylor polynomials on the same axis.  To make it pretty, I suggest using the command 
Plot[{Erf[x], f1, f2}, {x,-3,3}, PlotStyle-> {RGBColor[0,0,0], RGBColor[1,0,0], RGBColor[0,1,0]}].   This will make Erf[x] be black and the other functions different colors.  Preeeettty.

(d) Based on your graph, what do you think the interval of convergence of the Erf[x] Taylor series is?

Now that you're done, 
	(1) 	Clean up your work by deleting everything that's not needed.  
		There should only be the title, your names, section number, and the questions and your answers
		(with any needed explanations, graphs, etc.).
	(2) 	Save this to your disk.
	(3)	Go back to Blackboard and upload your final lab report to the Digital Drop Box, located
		in the User Tools area.  Remember that you have to first ADD your file to your digital drop box and 
		then SEND it to me!