Graphing Taylor Polynomials

Comparing a Function and its Taylor Approximation

The command below graphs a function (variable name: x), and its Taylor Polynomial. The first input is the function, the second the center, the third the radius (about the center) of the domain , the last one the degree of the Taylor polynomial.
The function's graph will be blue, its approximation has a red graph.

If "output" is set to "True", Mathematica will also show you the formula for the Taylor Polynomial approximation; if you choose a large degree for the approximation, you may want to set "output" to "False".

\(f[x_] = Tan[x]; 
appcenter = 0; 
appdegree = 14; 
viewradius = 2; 

    output = True; 


    g[x_] = Normal[Series[f[x], {x, appcenter, appdegree}]]; 

    If[output == True, Print[g[x]], ]\)\(\(Plot[{f[x], g[x]}, {x, appcenter - viewradius, \ 
        appcenter + viewradius}, \ 
      PlotLabel -> StringForm["Approx. of degree `` ", appdegree], 
      PlotStyle -> {{AbsoluteThickness[2], RGBColor[0, 0, 1]}, {
            AbsoluteThickness[2], RGBColor[1, 0, 0]}}, 	
      Epilog -> {AbsolutePointSize[10], Point[{appcenter, f[appcenter]}]}]; 
    \)\)

Etc.

Author: H. Knaust (helmut@math.utep.edu)
Created: August 2000
Last Edits: September 19, 2000