% preg1, lab10, 521230, S2-2011

% comprobar orden de metodos de Euler
h = [0.1 0.05 0.02 0.01 0.005 0.002 0.001];
emax_impl = zeros(length(h),1);
emax_expl = zeros(length(h),1);
for i = 1 : length(h)
    [t,y] = eulerimpl1d('func1_lab10','dfunc1_lab10',0,1,1,h(i));
    [te,ye] = eulerexpl1d('func1_lab10','dfunc1_lab10',0,1,1,h(i));
    emax_impl(i) = max(abs(y(2:end)-exp(-t(2:end))));
    emax_expl(i) = max(abs(ye(2:end)-exp(-te(2:end))));
end
% comprobar que los metodos tienen orden 1, la pendiente de las curvas
% (log(h),log(max error)) debe ser 1.
loglog(h,emax_impl);
hold on
loglog(h,emax_expl,'r');
loglog(h,h,'k');
legend('euler impl','euler expl','pendiente 1');