Mathematical Principles for Scientific Computing and Visualization  
http://www.farinhansford.com/books/scv
by Gerald Farin and Dianne Hansford


This notebook illustrates derivatives of a function.
1) The derivative function reveals local minima and maxima
2)  Taking the derivative of a curve is a roughing process. 
In general, the derivative is rougher than the original curve.


See Chapter 7: Background: Numerical Calculus for details.

Updated May 2008

(* Set output folder to folder this file lives in *)

(SetDirectory[ToFileName[Extract["FileName"/.NotebookInformation[EvaluationNotebook[]],{1},FrontEnd`FileName]]];) 

(*Define a function *)
g[x_]:=(Sin[6x]+ (2-2x))+4.5;

(* Plot it *)
gplot=Plot[{g[x],g'[x]},{x,-1,1},PlotStyle->{{Thickness[0.01`],GrayLevel[0.7]},{Thickness[0.01`], GrayLevel[0.0]}},AxesStyle->Directive[GrayLevel[0.0],Thickness[0.005]], Ticks->None, ColorOutput->CMYKColor]

(* Output plot to postscript *)
Export["derivex.eps",gplot];


(* =================  EXAMPLE 2 ======================================== *)


(* Define a function *)
f[x_]:=(x^4)+(1/15) Sin[10 x]+3;

(* Plot the function and its derivative *)
plotfct=Plot[{f[x],f'[x]},{x,-1,1},PlotStyle->{{Thickness[0.01`],GrayLevel[0.7]},{Thickness[0.01`], GrayLevel[0.0]}},AxesStyle->Directive[GrayLevel[0.0],Thickness[0.005]], Ticks->None, ColorOutput->CMYKColor]

(* Output plot to postscript file *)
Export["roughderiv.eps",plotfct];

(* ================= EXAMPLE 3 ======================================== *)

(* Define a function *)

h[x_]:=x^11+(1/55) (Sin[8 x]+Cos[8x]) +x +2.3;

(* Plot *)
hplot=Plot[{h[x],h'[x]},{x,-0.7,0.7},PlotStyle->{{Thickness[0.01`],GrayLevel[0.7]},{Thickness[0.01`], GrayLevel[0.0]}},AxesStyle->Directive[GrayLevel[0.0],Thickness[0.005]], Ticks->None, ColorOutput->CMYKColor]