% TABLE2_18  Computations for Table 2.18.
%
clear mc mp iq idelta irout
global mc mp iq idelta irout 
fprintf('\n')
disp('     The multiple-component discretization method')
disp('                applied to Example 2.44')
disp('                   (with Stieltjes)')
%disp('                    (with Lanczos)')
f1=' %8.0f %18.10e %10.2e %9.2e\n';
f2=' %38.2e %9.2e\n';
f3='                         %6.3f';
mc=2; mp=0; iq=1; idelta=1; 
N=40; Mmax=300; eps0=1000*eps;
abex=zeros(N,2);
irout=1;
%irout=0;
tic
[ab,Mcap,kount]=mcdis(N,eps0,@quadlag,Mmax);
t=toc;
abex(1,2)=1; k=(1:N-1)'; abex(2:N,2)=k.^4*pi^2./(4*k.^2-1);
errabm=max(abs(ab-abex)./moll(abex));
n=[1 2 7 16 27 40];
fprintf('\n')
disp('        n        beta_n          erra      errb')
n=[1 2 7 16 27 40];
errab=abs((ab(n,:)-abex(n,:))./moll(abex(n,:)));
abe=[(n-1)' abex(n,2) errab];
fprintf(f1,abe')
fprintf(f2,errabm)
fprintf('\n')
disp('                         timing')
fprintf(f3,t)
