(* Activity based on a worksheet from U. Maine (2010), which in turn came from ideas of Andew Boudreaux and Warren Christianson*)

Clear["Global`*"];ClearAll["Global`*"];

f[x_] := +8*Sin[1.5*x]+(x-1)^2-.3(x-3)^3

Plot[f[x],{x,0,10},PlotStyle->{Thick},PlotRange->{{0,10},{-10,25}}]

(* For purpose of Powerpoint, just the curve *)Plot[f[x],{x,0,10}, PlotRange->{{0,10},{-10,25}}, Axes->None, PlotStyle->{Thick}]

(* For purposes of Taylor expanding about interesting points, you might want to know these locations*)
FindRoot[f[x]==0,{x,2}]
FindRoot[f[x]==0,{x,4}]
FindRoot[f'[x]==0,{x,1}]
FindRoot[f'[x]==0,{x,3}]
FindRoot[f'[x]==0,{x,5}]
FindRoot[f''[x]==0,{x,2}]

ts[xx_,n_,x1_] := Normal[Series[f[y],{y,x1,n}]]/. y-> xx
(* "Normal" just stops the series after n terms *)

ts[x,2,0]

(* For each of the next three cases, let's plot the "Taylor approximation", to zeroth, then first, then second order, and see how well it does. Finally, we might pick a large n to see how well we can do *)

Plot[f[x],{x,0,10}, PlotRange->{{0,10},{-10,25}}, PlotStyle-> Thick]

(* Taylor expand around a point just left of the first zero crossing, where it looks pretty straight*)
(* Try changing the second argument in "ts" from 0 terms, to 1, to 2, etc *)
Plot[{f[x],ts[x,0,1.94]},{x,0,10}, PlotRange->{{0,10},{-10,25}}, PlotStyle-> Thick]

(* Taylor expand around a minimum. *)
Plot[{f[x],ts[x,0,2.924]},{x,0,10}, PlotRange->{{0,10},{-10,25}}, PlotStyle-> Thick]

(* Taylor expand around a zero-crossing*)
Plot[{f[x],ts[x,0,3.558]},{x,0,10}, PlotRange->{{0,10},{-10,25}}, PlotStyle-> Thick]

(*Maclaurin series. Try setting second argument, n=10, 20, 40, ... *)
Plot[{f[x],ts[x,0,0]},{x,0,10}, PlotRange->{{0,10},{-10,25}}, PlotStyle-> Thick]