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

I.  Laboratory Objectives
	Use Mathematica to explore
		Power Series
		Taylor Series

II.  Formatting and Syntax Information

Series[f, {x, (Subscript["\!\(\*StyleBox[\"\\\"x\\\"\", \"TI\"]\)", 0]), n}] 	This generates a power series 
					expansion for f about the point 
					x = (Subscript[x, 0]) to order (((x - (Subscript[x, 0])))^n)
	Normal[expression]		Converts a Taylor Series to a 
					Taylor Polynomial by truncating
					the higher order terms

Power Series

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

 \(TraditionalForm\`∑\+\(n = 0\)\%∞\(\( c\_n\)(x - a)\)\^n\)
 
 This is an infinite polynomial written in terms of powers of (x - a).

Taylor Series

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

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

Thus a Taylor Series is the particular Power Series whose coefficiants are given by (Subscript[c, n]) =  (((f^((n)))(a))/(n!)).

Again, a Taylor Series is an infinite polynomial.

A Taylor Polynomial of degree k is the truncated Taylor Series of that degree.  A Taylor Polynomial is a finite polynomial.

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, (Subscript["\!\(\*StyleBox[\"\\\"x\\\"\", \"TI\"]\)", 0]), n}] generates a power series expansion for f about the point x = (Subscript[x, 0]) to order (((x - (Subscript[x, 0])))^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, 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.

taylseries = 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:

tayl10poly[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])

\(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.  We need to check these endpoints separately.

At x  =  0 we have the series  (∑_(n = 1)^∞)(((((-1))^(n - 1)) (((-1))^n))/n)  =  (∑_(n = 1)^∞)((((-1))^(2  n - 1))/n)
\(This\ can\ be\ further\ simplified\ \(to : 
		∑\+\(n = 1\)\%∞\((\(-1\))\)\/n\)\  = \ \ \(-\ \(∑\+\(n = 1\)\%∞ 1\/n\)\)\)

This is just (-1) times the divergent Harmonic Series, so at x = 0 the series diverges.

\(\(\(
\)\(At\ x\  = \ \(2\ we\ have\ \ \(∑\+\(n = 1\)\%∞\(\(\((\(-1\))\)\^\(n - 1\)\) \((1)\)\^n\)\/n\) = \ \ \(∑\+\(n = 1\)\%∞\((\(-1\))\)\^\(n - 1\)\/n\  = \ \ \(-\(∑\+\(n = 1\)\%∞\((\(-1\))\)\^n\/n\)\)\)\)\)\)\)

This is just (-1) times the Alternating Harmonic Series which is conditionally convergent.
So at x = 2, the series converges.

Thus the series \(ln \((x)\) = \ ∑\+\(n = 1\)\%∞\(\(\((\(-1\))\)\^\(n - 1\)\) \((x - 1)\)\^n\)\/n\) converges for 0 < x ≤ 2.  To see what 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], tayl10poly[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 
	y1 = Log[x_]  and y2 = tayl10poly[x_]

By evaluating the data points along y1 and y2 you are testing out the Taylor Polynomial of degree 10 to see how accurate it is against the function ln(x).  
a.  Evaluate both   y1 =  Log[x_] and  y2 = tayl10poly[x_] for the following values of x:
	x = .32
	x = .5
	x = .75
	x = 1
	x = 1.3
	x = 1.8
	x = 2

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 (π/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.

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 to tell the radius and interval of convergence 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?

g.  Test out the Taylor Polynomial of degree 8 to see how accurate it is against the function y = sin (x) in a neighborhood around (π/4).   
Evaluate both your Taylor Polynomial and Sine[x] for the following values of x:
	
	x = -(π/4),  x = 0,  x = .5,   x = .75, x = .8 ,x = (π/4),  , x = 1, x = (π/2),    x = ((3  π)/2)

Where is the Taylor Polynomial closest to the value of the sine function?

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?

BONUS:  Prove your answer to part (d) using the Ratio Test and your answer to part (b).