% Numerical Mathematics and Computing, Fifth Edition
% Ward Cheney & David Kincaid
% Brooks/Cole Publ. Co.
% (c) 2004
%
% file: cpb6.2..m

% evaluate test integrals
% Computer Problem 6.2.9
%
format long

%CPb 6.2.8c (cont.)

A = quad('sin(x).*(x.^(-3))', 1, pi, 1.e-12);
B = quad('sin(x).*(x+pi).^(-3)', 0, pi, 1.e-12);

n = 10000;
S = 0;
for j=1:n
  k = n+1-j;
  a = 2*k*pi;
  b = (2*k+1)*pi;
  c = (2*k+2)*pi;
  u = quad('sin(x).*(x.^(-3))',a, b, 1.e-12);
  v = quad('sin(x).*(x.^(-3))',b, c, 1.e-12); 
  S = S + u - v;
end
S = S + A + B
