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

function demo_gregory

f=@(x) exp(x)+x.^2;
prim=@(x) exp(x)+x.^3/3;

estremi(1)=0; estremi(2)=1;

I=prim(estremi(2))-prim(estremi(1));

NV=10:10:50;
M=length(NV);

for k=1:M
    N=NV(k);
    Inum(k)=gregory(f,N,estremi);
    err(k)=abs(I-Inum(k));
    fprintf('\t k: %1.0f err:%1.3e \n',k,err(k));
end

fprintf('\n');

% Risultati:
% >> demo_gregory
% k: 1 err:4.374e-04
% k: 2 err:4.669e-05
% k: 3 err:1.315e-05
% k: 4 err:5.410e-06
% k: 5 err:2.729e-06
% >>
