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



Derivatives

Derivatives help us understand the behaviour of functions.
Derivatives are functions themselves.

Suppose f[t] = 40t^2 represents milage driven over time t (hours).

The derivative of f, called fderiv[t] below, represents the instantaneous velocity at time t when f represents distance.  Sometimes the derivative is written as f'(t). Let h be an interval of time.

For the function here: f'(t) = lim as h->0 (40(t+h)^2 - 40t^2)/h = 80t miles/hour (mph). Notice the units.

The velocity for our given function is linear over time -- our speed is increasing over time. (This isn't a very realistic model -- after 5 hours we are going 400 mph!) 

The second derivative is the derivative of the first derivative, and it represents acceleration when f' represents velocity; thus it is the rate of change of velocity.
f''(t) = (f'(t))' = lim as t->0 of (80(t+h) - 80t) / h = 80 miles/hour^2
Therefore, in this example, acceleration is constant.

Needs["PlotLegends`"]

f[t_] := 40t^2
fderiv[t_] := 80*t
fsecderiv[t_] := 80

Plot[{f[t], fderiv[t], fsecderiv[t]},{t,0,5}, PlotStyle->{Thickness[0.005], Thickness[0.002],Thickness[0.002]}, PlotLegend->{Style["f", 15,  FontFamily->"Helvetica"], Style["f'", 15,  FontFamily->"Helvetica"], Style["f''", 15,  FontFamily->"Helvetica"]},LegendPosition->{0.99, -0.3} ]

Let' s try a more complicated function to see how f' and f'' behave

(* Concave or concave down *)
(* Notice where the velocity is zero, and that the acceleration is always negative for the concave function *)

g[t_] :=-t^2 +2t +1
gderiv[t_] := -2t + 2
gsecderiv[t_] := -2

Plot[{g[t], gderiv[t], gsecderiv[t]},{t,-5,5}, PlotStyle->{Thickness[0.005], Thickness[0.002],Thickness[0.002]}, PlotLegend->{Style["g", 15,  FontFamily->"Helvetica"], Style["g'", 15,  FontFamily->"Helvetica"], Style["g''", 15,  FontFamily->"Helvetica"]},LegendPosition->{0.99, -0.3} ]

(* Convex or Concave up *) 
(* Notice where the velocity is zero, and that the acceleration is always positive for this convex function *)

g2[t_] :=t^2 +2t +1
g2deriv[t_] := 2t + 2
g2secderiv[t_] := 2

Plot[{g2[t], g2deriv[t], g2secderiv[t]},{t,-5,5}, PlotStyle->{Thickness[0.005], Thickness[0.002],Thickness[0.002]}, PlotLegend->{Style["g", 15,  FontFamily->"Helvetica"], Style["g'", 15,  FontFamily->"Helvetica"], Style["g''", 15,  FontFamily->"Helvetica"]},LegendPosition->{0.99, -0.3} ]

(* This example is more complicated *)
(* Notice the local max and min function values and the corresponding first derivative there *)
(* Acceleration is zero where the function changes from concave to convex or visa versa. *)

hfct[t_] :=3t^4 - 4t^3 -12t^2 + 8
hderiv[t_] := 12t^3 -12t^2 -24t
hsecderiv[t_] := 36t^2 -24t -24

Plot[{hfct[t], h'[t], hsecderiv[t]},{t,-3,3}, 
PlotRange->{-30,30},
PlotStyle->{Thickness[0.005], Thickness[0.002],Thickness[0.002]}, PlotLegend->{Style["h", 15,  FontFamily->"Helvetica"], Style["h'", 15,  FontFamily->"Helvetica"], Style["h''", 15,  FontFamily->"Helvetica"]},LegendPosition->{0.99, -0.3} ]

k[x_] := 3x^2 + 2Sin[5x];

Manipulate[Plot[{k[x], k'[x]}, {x,0,b}], {{b,1},1,10}]