
function esercizio1

hV=[0.2 0.1 0.05];
sol=@(x) atan(x);
fcn=@(x,y) 0*x+(cos(y)).^2;
t0=0; y0=0; t_end=10;
for k=1:length(hV)
    h=hV(k);
    
    % ... calcolo soluzione ...
    [t,yt] = eulero_esplicito(t0,y0,t_end,h,fcn);
    
    % ... calcolo errori ...
    solt=feval(sol,t);
    abserr=abs(solt-yt);
    relerr=abs(solt-yt)./abs(solt);
    
    % ... storage ultimo errore ...
    ae_10(k)=abserr(end);
    
    % ... plot errori ...
    
    % .. errore assoluto ..
    figure(2*k-1);
    semilogy(t,abserr);
    hold on;
    title('Errore assoluto');
    hold off;
    
    % .. errore relativo ..
    figure(2*k);
    semilogy(t,abserr);
    hold on;
    title('Errore relativo');
    hold off;
    
    pause;
    
end

rat=ae_10(1:end-1)./ae_10(2:end);
for k=1:length(rat)
    fprintf('\n \t [%3.0f] %1.4e',k,rat(k));
end

fprintf('\n')