function [ab,dig]=dig_binet(N,dig0,dd,nofdig)
%DIG_BINET Number of digits needed for the Binet polynomials.
%   [AB,DIG]=DIG_BINET(N,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-exp(-|x|)) on [-Inf,Inf] to an accuracy of
%   NOFDIG decimal digits using the classical Chebyshev
%   algorithm. 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.

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