% NOME: ... COGNOME: ... MATRICOLA: ...

function demo_midpoint_composta
f=@(x) sin(x).^2;
estremi(1)=0;
estremi(2)=pi/3;

for k=1:3
    N=100^k;
    S(k)=midpoint_composta(f,N,estremi);
    fprintf('\t k: %1.0f S(k):%1.15e \n',k,S(k));
end
err(1)=abs(S(3)-S(1));
err(2)=abs(S(3)-S(2));
fprintf('\t err(1): %1.3e \n',err(1));
fprintf('\t err(2): %1.3e \n',err(2));

% Risultati:
% k: 3 S(k):3.070924246521495e-01 
%	 err(1): 3.957e-06 
%	 err(2): 3.957e-10 
