%TEST_PRECISION_MOD3 Precision required for Algorithm 3 in the
%   case of Example 3 
%
global dig imod m
f0='%8.0f %5.0f %5.0f %14.4e %12.4e\n';
f1='%8.0f %24.16e %24.16e\n';
disp('      N     m     dig      erra         errb')
for N=80:20:100
  for m=10:2:18
    abp=zeros(N,2);
    k=0;
    dig1=8; dig2=80;
    nd=1+(dig2-dig1)/4;
    err=zeros(nd,3);
    for dig=dig1:4:dig2
      k=k+1;
      abp0=abp;
      digits(dig);
      z=vpa(i/1000);
      alpha=-1/2;
      ab0=sr_jacobi01(dig,N);
      imod=1;
      ab=mod_d(N,m,z,ab0,@rho01_mu); 
      imod=2;
      ab=mod_d(N,m,z,ab,@rho01_mu);
      abp=real(subs(ab));
      err0=[abs(abp(1,1)-abp0(1,1)) ...
      abs((abp(1,2)-abp0(1,2))/abp(1,2))];
      err1=max(abs(abp(2:N,:)-abp0(2:N,:))); 
      err(k,2:3)=[max(err0(1),err1(1)) max(err0(2),err1(2))];
%      err(k,2:3)=max(abs(abp-abp0));
      if max(err(k,2:3))<.5e-16, break, end
    end
    d=(dig1:4:dig2)';
    err(:,1)=d;
    for n=1:k
      fprintf(f0,N,m,err(n,1),err(n,2),err(n,3))
    end
    fprintf('\n')
  end
end
