clear all; clc;

t0 = 0;
y0 = 1;
T = 2;

f = @(t,y) t * y;

h = 2e-1;

t = t0:h:T;
y_true = exp(t.^2/2);
y_1 = euler_explicit(h, f, t0, y0, T);
y_2 = euler_implicit(h, f, t0, y0, T);
y_3 = euler_improved(h, f, t0, y0, T);
y_4 = runge_kutta_klass(h, f, t0, y0, T);

figure(1), clf
plot(t,y_true,'-ok', t, y_1, '-b+',t,y_2,'-g*',t,y_3,'-cd',t,y_4,'-rs',...
    'LineWidth',2)
legend( 'Exakt','Euler expl.','Euler impl.','Euler besser','klass. RKV', 'Location', 'NorthWest')
xlabel('t','FontSize',14)
ylabel('y(t)','FontSize',14)
set(gca,'FontSize',13)

