  function ToughProblemCVL()
% Through experimentation we decided to use
% quadgk and play with two parameters.
% The first is an absolute error tolerance..
tolValue = .0000000001;
% The second controls the numberof allowable subintervals. This
% relates to the number of f-evaluations
MaxIntCount = 20000000;
% These values were determined through experimentation.
% Let I(a,b) = integral from a to b of cos(log(x)/x)/x;
% Let alpha(k) = I(1/2^k , 1/2^{k-1)) and note that
%   alpha(1) + alpha(2) + ...+ alpha(n) + ...  -----> Iexact where
Iexact = .3233674316;
% We will use quadgk to compute the alpha(1),...,alpha(N) where
N = 18;   % N = 25 gives 10 significant places
clc
fprintf(' k           I(k)         |I(k) - Iexact|\n')
fprintf('--------------------------------------------------------\n')
I = 0;
for k=1:N
    % Compute the integral from 1/2^k  to 1/2^(k-1)...
    a = 1/2^k;
    b = 2*a;
    alpha(k) = quadgk(@MyF,a,b,'abstol',.000000001,'MaxIntervalCount',MaxIntCount);
    % I is the integral from 1/2^k to 1
    I = I + alpha(k);
    fprintf('%3d    %13.10f      %10.3e \n',k,I,abs(I-Iexact))
end


function y = MyF(x)
   y = cos(log(x)./x)./x;
  
   
   % -1 if no playing with quadgk's parameters
   % -1 no comments
   % -1 if your strategy really doesn't scale to get 10 digits