function [ab,dig]=dig_hrsqgbinet(N,a,dig0,dd,nofdig)
%DIG_HRSQGBINET Number of digits needed for the half-range squared 
%generalized Binet weight function.
%   [AB,DIG]=DIG_HRSQGBINET(N,A,DIG0,DD,NOFDIG) determines the number 
%   DIG of digits needed to obtain the first N recurrence coefficients 
%   for the weight function w(x)=[log(1-A*exp(-x))]^2 on [0,Inf] to an
%   accuracy of NOFDIG decimal digits using a moment-based method. The 
%   routine successively increments an initial estimate DIG0 by DD units 
%   until the required accuracy is achieved. The recurrence coefficients 
%   to NOFDIG digits are placed into the Nx2 array AB.

maxerr=1; eps0=.5*10^(-nofdig);
i=dig0-dd; 
while maxerr>eps0
  i=i+dd; dig=i
  if i==dig0
    mom=smom_hrsqgbinet(dig,N,a);
    ab0=schebyshev(dig,N,mom');
    ab0p=vpa(ab0,nofdig);
  else
    mom=smom_hrsqgbinet(dig,N,a);
    ab1=schebyshev(dig,N,mom');
    serr=abs((ab1(:,2)-ab0(:,2))./ab1(:,2));
    err=double(serr);
    maxerr=max(err) 
    ab0=ab1;
    ab=vpa(ab0,nofdig);
  end
end
