Derivatives

slope[ ] is an approximation to the derivative  using a step length h.

h=0.9; (* or smaller, for better approximation *)
slope[f_,x_]:=f'[x]; (* M's built-in derivative, works for any f! *)
f[x_]:=Sqrt[x] +0.1Sin[5x]; (*or other f *)


(* secant[f_,x0_,x_]:= (1-u[x0,x])*f[x0-h]  +  u[x0,x]*f[x0+h];*)
secant[f_,x0_,x_]:=((x0+h-x) *f[x0-h]  + (x-x0+h)*f[x0+h])/(2h);
(* equation of secant line at x0*)
tangent[f_,x0_,x_]:=f[x0]+(x-x0)*slope[f,x0];(* equation of tangent line at x0*)

x0=1.0;
point={x0,f[x0]};

point1 = {x0-h, f[x0-h]};
point2 = {x0+h, f[x0+h]};
plotp1 = Graphics[{PointSize[Large],Blue,Point[point1]}];
plotp2 = Graphics[{PointSize[Large],Blue,Point[point2]}];

argpic= Graphics[{PointSize[Large],Red,Point[point]}];
pic1= Plot[tangent[f,x0,x
],{x,0,1},PlotStyle-> Thick];
pic2= Plot[secant[f,x0,x],{x,-1,2},PlotStyle-> {Thick,Red
}];
pic3=Plot[f[x],{x,0,3},PlotStyle->Thick];


(*Show[{pic1,pic2,pic3, argpic}]*)

fctpic=Plot[{tangent[f,x0,x],secant[f,x0,x],f[x]},{x,0,2 },PlotStyle-> Thick,PlotLabel->Style["tangent & secant",FontSize->18,Bold]];
Show[{fctpic,argpic, plotp1, plotp2, pic2}]

Manipulate[
Plot[{f[x],tangent[f,x0,x]},{x,0.001,3},PlotStyle->Thick,PlotRange->All],{x0,0.001,3}]

For small values of h, the approximated slope and the actual slope are close:

Plot[{f'[x],slope[f,x]},{x,-5,5},PlotStyle->Thick]

f[x_]:=x^3-8x^2+8x+50;
f'[x];
f''[x];
Plot[{f[x],f'[x],f''[x]},{x,-3,6},PlotStyle->Thick]