% Explicit Euler Convergence
%
tmax = 1;
timesteps = 1:10;
for k = timesteps
    dt = 2^(-k);
    n=tmax/dt;
    t=0; u=1;
    for j=1:n
        u = u + dt*f(t,u);;
        t = t + dt;
    end
    uf(k) = u;
end
loglog(2.^(-timesteps),abs(uf-1/2),'o-'); xlabel('dt'); ylabel('error');