Section 2.2

Calculus I
Andy Long

(* Section 2.2: derivative as a function *)
ClearAll["Global`*"]

(* Exercise 7, p. 111: *)
f[x_]:=Sqrt[x]
a=1
R={{0,2},{-.1,1.5}};
m=Limit[(f[x]-f[a])/(x-a),x->a]
m=Limit[(f[a+h]-f[a])/h,h->0]
PlotA=Plot[{f[x],m(x-a)+f[a]},{x,a-1,a+1}];
PlotB=ListPlot[{{a,f[a]}},PlotMarkers->{"☹"}];
Show[PlotA,PlotB,PlotRange->R]

(* Now let's see that in action: *)
list={};
Manipulate[
Module[
{m},
m=Limit[(f[a+h]-f[a])/h,h->0];
list=Append[list,{a,m}];
PlotA=Plot[{f[x],m(x-a)+f[a]},{x,0,3}];
PlotB=ListPlot[{{a,f[a]}},PlotMarkers->{"☹"}];
PlotC=ListPlot[list];
Show[PlotA,PlotB,PlotC,PlotRange->R]
]
,{a,0,2}
]

Plot [{f[x],f'[x]},{x,0,3},PlotRange->R]