a=0;
b=1;
m=3;

file=fopen('tabella.txt','w');
fprintf(file,'***********************Tabella Esame***********************\n');
fprintf(file,'\n    %s\t%s\t\t\t%s \t\t \n\n','n','Iv','Errore');

for k=0:12
f = @(x,k) x.^k;
Iv(k+1) = simpson(@(x)f(x,k),a,b,m);
errore(k+1) = abs(Iv(k+1) - 1/(k+1));

    fprintf(file,'    %d  %19.16f %16.5e\n',[k,Iv(k+1),errore(k+1)]);
end

fclose(file);

figure(1)
semilogy(0:k,errore,'r*')

