clf
clear all
x=linspace(-1,1,6);
y=linspace(1,3,6);
[X,Y]=meshgrid(x,y);


axis([-1.5,1.5,0.5,3.5])

%y'(x)=2+2x-y
XKAT=ones(size(X))
YKAT=2+2*X-Y
quiver(X,Y,XKAT,YKAT)
shg
hold on
pause
xfin=-1.1:0.01:1.4;
for c=[1,1.3,1.6,5/exp(1)]
    yfin=2*xfin+exp(-xfin)*c;
    plot(xfin,yfin,'r','linewidth',2)
    shg
    pause
end
%Euler framåt, med start i u(-1) för c=1.3:
% Tag en steglängd h=0.2 och stega fram till 1.4.
t(1)=-1; u(1)=1.3*exp(1)-2; % u(-1)=c*exp(1)-2;
k=1;h=0.2;
for k=1:12
    u(k+1)=u(k)+h*(2+2*t(k)-u(k));
    t(k+1)=t(k)+h;
    plot([t(k),t(k+1)],[u(k),u(k+1)],'g');
    plot([t(k),t(k+1)],[u(k),u(k+1)],'*g');
    
    k=k+1;
    pause
end

pekare=text(0,0.7,'Euler');
set(pekare,'color','g')
