Taylor Series

Therese Shelton

Clear[k,x,x0,xmin,xmax,ymin,ymax,numTerms, f,g];
(* g is the function for which we find Taylor Series approximations about x0 up to 
order numTerms.  Our graphing window uses x between xmin and xmax 
and y between ymin and ymax. *)


(* CHANGE THESE AND RE-EXECUTE  *)
g[x_]:=(E^(-x))Cos[x];
x0=0;
xmin=-9;xmax=4;
ymin=-15;ymax=8;
numTerms=20;


(* LEAVE THIS PART ALONE  *)
Manipulate[
f[x_]=Normal[Series[g[x],{x,x0,k}]];
Plot[{g[x],f[x]},{x,xmin,xmax},PlotRange->{ymin,ymax},PlotStyle->{{Red,Thickness[.01]},{Green,Thickness[.01],Dashing[{.05,.05}]}}],
{{k, 1, "number of series terms"}, 1, numTerms,1}
]

ORIGINAL SETTINGS
 
g[x_] := Cos[x];                
x0 = 0;                                   
xmin = -12; xmax = 12;
ymin = -4; ymax = 4;      
numTerms = 20;                 


ALSO TRY 

g[x_] :=  (e^(-x)) Cos[x];                
x0 = 0;                                   
xmin = -9; xmax = 4;
ymin = -15; ymax = 8;      
numTerms = 20;      

AND

g[x_] := x^5/5 - 3 x^3 + 5 x + 1;                
x0 = 1.;                                   
xmin = -10; xmax = 10;
ymin = -25; ymax = 30;      
numTerms = 20;