
function demo_midpoint

f=@(x) (exp(x)-1)./x;
estremi=[0 1];

for k=1:3
    N=100^k;
    S(k) = midpoint (f,estremi,N);
    fprintf('\n \t S( %2.0f ): %1.15f',k,S(k));
end

err(1)=abs(S(3)-S(1)); 
err(2)=abs(S(3)-S(2));

fprintf('\n \t err(1): %1.3e',err(1));
fprintf('\n \t err(2): %1.3e',err(2));

fprintf('\n');

% RISULTATI.
% demo_midpoint
% 
%  	 S(  1 ): 1.317900068124880
%  	 S(  2 ): 1.317902151246070
%  	 S(  3 ): 1.317902151454383
%  	 err(1): 2.083e-06
%  	 err(2): 2.083e-10

