% EXAMPLE3_42  Computations for Example 3.42.
%
clear mc mp iq idelta irout AB Z eps0 Nmax ab0 M
global mc mp iq idelta irout AB Z eps0 Nmax ab0 M
f1='%4.0f %5.0f %24.14e %14.4e %7.0f %7.0f\n';
disp('                            M=2*floor((3N+2)/2)')
%disp('                                  M=2*N')
%disp('                            M=2*floor((N+1)/2)')
%disp('                                   M=2')
%disp('                                   M=0')
fprintf('\n')
mc=1; mp=0; iq=1; idelta=2; irout=1; 
AB=[-1 1];
eps0=100*eps; Nmax=100; om=1.1;
Nm=4;
%Nm=5;
%Nm=7;
%Nm=10;
ab0=r_jacobi(Nmax);
exact=4.4677736463877657896;
disp('   n     m          integral              error        Ncap   kount')
for N=1:Nm
  M=2*floor((3*N+2)/2);
%  M=2*N;
%  M=2*floor((N+1)/2);
%  M=2;
%  M=0;
  sgn=1;
  for m=1:M
    sgn=-sgn;
    Z(m,1)=sgn/(om*floor((m+1)/2)); Z(m,2)=1;
  end
  [abmod,Ncap,kount]=r_mod(ceil(3*N/2)+1,ab0);
  xw=kronrod_rational(N,abmod);
  int=sum(xw(:,2).*fex31(xw(:,1),om));
  err=abs((int-exact)/exact);
  fprintf(f1,N,M,int,err,Ncap,kount)
end
