
function esercizio3variante

% ... impostazioni iniziali ...
hV=[0.1 0.05 0.02 0.01 0.001];
lambda=-100;
sol=@(x) exp(lambda*x);
fcn=@(x,y) 0*x+lambda*y;
t0=0; y0=1; t_end=100; tol=10^(-6);

sol_100=feval(sol,100);

% ... test ...
for k=1:length(hV)
    
    h=hV(k);
    
    % ... valuta 1+h*(-100) ...
    fprintf('\n \n \t h: %1.5f',h);
    if abs(1-100*h) < 1
        fprintf('\n \t |1+h*lambda|<1');
    else
        fprintf('\n \t |1+h*lambda| >= 1');
    end
    
    % ... esegui test ...
    n = fix((t_end-t0)/h)+1;
    t = linspace(t0,t0+(n-1)*h,n)';
    yt_EE=(1+h*lambda).^(0:n-1);
    yt_EI=1./((1-h*lambda).^(0:n-1));
    % yt_CN=((2+h*lambda).^(0:n-1))./((2-h*lambda).^(0:n-1)); % MALE!
    yt_CN=((2+h*lambda)/(2-h*lambda)).^(0:n-1);
    
    % ... calcola errori assoluti ...
    
    ae_EE_100(k)=abs(sol_100-yt_EE(end));
    ae_EI_100(k)=abs(sol_100-yt_EI(end));
    ae_CN_100(k)=abs(sol_100-yt_CN(end));
    
    % ... stampa risultati ...
    fprintf('\n \t ae_EE_100: %1.3e',ae_EE_100(k));
    fprintf('\n \t ae_EI_100: %1.3e',ae_EI_100(k));
    fprintf('\n \t ae_CN_100: %1.3e',ae_CN_100(k));
    
end

fprintf('\n');