% EXAMPLE2_46 Computations for Example 2.46.
%
clear mc mp iq idelta mc mp iq idelta k2 abm
global mc mp iq idelta
global k2 abm
fprintf('\n')
disp('            Recursion coefficients for an elliptic weight')
disp('            function computed by the discretized modified')
disp('            Chebyshev algorithm')
fprintf('\n')
fprintf('\n')
f1='                               k2=%5.3f\n';
f2='                        Mcap=%3.0f   kount=%3.0f\n\n';
f3='%24.0f %20.15f\n';
N=40; Mmax=600; eps0=1000*eps;
mc=1; mp=0; iq=1; idelta=1;
abm=r_jacobi(2*N-1,-1/2);
for k2=[.1 .5 .9 .999]
  fprintf(f1,k2)
  [ab,Mcap,kount]=mcchebyshev(N,eps0,@quadch,Mmax);
  fprintf(f2,Mcap,kount)
  disp('                       n         beta_n')
  if k2==.1
    n=[1 2 6 12];
    for k=1:4
      fprintf(f3,n(k)-1,ab(n(k),2))
    end
    fprintf('\n')
  elseif k2==.5
    n=[1 2 9 21];
    for k=1:4
      fprintf(f3,n(k)-1,ab(n(k),2))
    end
    fprintf('\n')
  elseif k2==.9
    n=[1 2 9 40];
    for k=1:4
      fprintf(f3,n(k)-1,ab(n(k),2))
    end
    fprintf('\n')
  else
    n=[1 2 9 20 40];
    for k=1:5
      fprintf(f3,n(k)-1,ab(n(k),2))
    end
  end
  if Mcap>Mmax, break, end
end
