% TABLE2_14 Computations for Table 2.14.
%
clear a b mc mp iq idelta irout eps0 tc AB Mcap kount
global a b mc mp iq idelta irout eps0 tc AB
global Mcap kount
f1=' %4.0f  %18.10e %18.10e %10.2e %9.2e\n';
f2=' %54.2e %9.2e\n';
fprintf('\n')
disp('                Results for Example 2.40')
disp('                      (with mc=4)')
%disp('                      (with mc=6)')
N=160; eps0=1e3*eps;
mc=4; 
t1=-1; t2=-1/2; t3=0; t4=1/2; t5=1;
a=-1/2; b=1/2; g2=1/3; g3=1; g4=-1/3;
tc=[[t1 b];[t2 g2];[t3 g3];[t4 g4];[t5 a]];
%mc=6; 
%t1=-1; t2=-7/8; t3=-3/4; t4=-1/2; t5=0; t6=1/2; t7=1;
%a=-1/2; b=1/2; g2=-1/2; g3=-1/2; g4=1/3; g5=1; g6=-1/3;
%tc=[[t1 b];[t2 g2];[t3 g3];[t4 g4];[t5 g5];[t6 g6];[t7 a]];
irout=1;
absti=r_gjacobi(N,a,b);
irout=0;
ablan=r_gjacobi(N,a,b);
discrabm=max(abs(absti-ablan)./moll(ablan));
n=[1 40 80 120 160];
fprintf('\n')
  disp('    n           a                  b            discra    discrb')
discrab=abs((absti(n,:)-ablan(n,:))./moll(ablan(n,:)));
abd=[(n-1)' ablan(n,:) discrab];
fprintf(f1,abd')
fprintf(f2,discrabm')
