Messing with Taylor Polynomials

Math 151-03 (Pelsmajer)
Adam Rumpf
March 5, 2014

Directions:
Read through this workbook, evaluating the Mathematica code as you go.  Do the exercises.  Ask questions as needed!
As before, you will need to write up your investigations in the form of a lab report.

Taylor Polynomials

Many functions can be usefully approximated with polynomials, called “Taylor Polynomials”.  Although we haven’t covered this in class yet, Mathematica can produce these polynomials for you.  

For example, this polynomial approximates Cos(x).

f[x_]=Normal[Series[Cos[x],{x,0,10}]]
Plot[{f[x],Cos[x]},{x,-2Pi,2 Pi}  , PlotRange->{-2,2}]

The Taylor Polynomial above is 1-((x^2)/2)+((x^4)/24)-((x^6)/720)+((x^8)/40320)-((x^10)/3628800), and it appears to approximate Cos(x) fairly closely on the interval [-4,4].

The approximation is more accurate near its “center”, an x-value that you will choose.  
In the above example, the Taylor Polynomial is centered at x = 0.  

With higher degree polynomials, you can have a more accurate approximation.  
In the above example, the degree of the polynomial is 10.

How to do it yourself

You must specify (1) the function, and (2) the x-value where you will “center” the approximation, and (3) the degree of the Taylor Polynomial.

For example, the Taylor Polynomial approximating Sin(x), centered at x = 2.5, of degree 6:

g[x_]=Normal[Series[Sin[x],{x,2.5,6}]]

Plotting it together with Sin(x):

Plot[{g[x],Sin[x]},{x,-4Pi,4 Pi} , PlotRange->{-2,2}]

Exercise 1

Where (for what x-values) is the above approximation accurate?
Then, experiment to find a Taylor Polynomial approximation of Sin(x) which is accurate on (-10,10).

Lots of Taylor Polynomials

You can also try different centers and degrees interactively.  

Run the following code and then mess around with the sliders to see how it works.  Start by moving the center “a” around and see what happens.  Then leave “a” alone, and gradually increase the degree “n” and see what happens.  (Then try whatever you want to see.)  You can click on the little “+” next to each slider to see the numbers.

Manipulate[Plot[Evaluate[{Normal[Series[Cos[x],{x,a,n}]],Cos[x]}],{x,-4Pi,4Pi}, PlotRange-> {-2,2} ,Epilog-> {PointSize[0.02],Point[{a,0}]}],{n,1,20,1},{a,-4Pi,4Pi}]

Exercise 2

Copy-and-paste the previous code below, then modify it so that (1) the function is 1/x, (2) the x-values (for both the visible domain and the centers) go from -2.5 to 2.5, and (3) the visible range has y from -10 to 10.
(Ask for help if needed - this exercise is just to learn the basics, it’s not the point of this lab!)

Exercise 3

Using the result from Exercise 2, play with the sliders to answer these questions:

Can you find a Taylor Polynomial that is a good approximation over the entire visible interval?  If you can’t get an appoximation that is good over the entire interval, can you get approximations that are good on fairly large intervals?  What sort of intervals can you get (meaning: intervals where the approximation is good)?  And describe any interesting patterns that you notice.

Exercise 4

Repeat Exercises 2 and 3 for:

(a) Tan(x) over the domain [-3.5, 3.5], with range of y-values [-20,20].

(b) 1/((x^2)-4) over the domain [-4,4], with range of y-values [-2,2].

(c) (e^(-(x^2))) over the domain [-5,5] with range of y-values [0,2].  (Use “Exp”.)

(d) CubeRoot[x] over the domain [-3,3] with range of y-values [-2,2].  (If “CubeRoot” doesn’t work, then use this:
      Root[#^3-x&,1]
(Mathematica will complain, but it will work.)

(e) -12 x+6 (x^3)-2 (x^6)+4 (x^8)-(x^10) over [-2,2] with y-range [-10,40].