Off[General::spell1]; 
Clear[FirstRich,f0,x0, M,tau];
FirstRich[f0_,x0_,M_,tau_] :=
Module[{f,j,h,a,b,r1,r2,
         diff,ratio,oldratio,Cond},
  Set@@{f[x_],f0};
  h=0.5; k =0;
  Cond = 0; oldratio = 0; 
  r2 = N[f[x0+h]-f[x0-h],digit];
  While[Cond ==0 && k <=M,
    diff = N[f[x0+h]-f[x0-h],digit];
    r1 = N[0.5 * diff /h,digit];
    ratio = r1 + (r1-r2) /3; 
   Print["k =", k, "\t    
      f'[",x0,"] ~ ",N[ratio,16]];
   If[Abs[ratio - oldratio] <= tau,   
       Cond=1]; 
   h = N[h/2,digit];  
   r2 = r1; 
   oldratio = ratio;
   k = k +1 ]; ];
On[General::spell1];

Clear[digit]; 
digit=16;

Clear[f];
f[x_] = ArcTan[x];

FirstRich[f[x],Sqrt[2], 20, 10^(-12)]

FirstRich[f[x],Sqrt[2], 20, 10^(-14)]

Off[General::spell1]; 
Clear[SecondRich,f0,x0, M,tau]; 
SecondRich[f0_,x0_, M_,tau_] :=
Module[{f,j,h,a,b,r1,r2,
         diff,ratio,oldratio,Cond},
  Set@@{f[x_],f0};
  h=1; k =0;
  Cond = 0;  oldratio=0;
  r2 = N[f[x0+h]-2f[x0]+f[x0-h],digit];
  While[Cond ==0 && k <=M,
    diff = N[f[x0+h]-2f[x0]+
       f[x0-h],digit];
    r1 = N[diff /h^2,digit];
    ratio = r1 + (r1-r2) /3; 
   Print["k =", k, "\t   
     f''[",x0,"] ~ ",N[ratio,16]];
   If[Abs[ratio - oldratio] <= tau,
      Cond=1]; 
   h = N[h/2,digit];  
   r2 = r1; 
   oldratio = ratio;
   k = k +1 ]; ];
 On[General::spell1];

Clear[f];
f[x_] = ArcTan[x];

SecondRich[f[x],Sqrt[2], 20, 10^(-10)]