% Harj. 2 AV

% Teht. 1
varit=['mcrgbk'];varit=[varit,varit];varit=[varit,varit];
y=inline('exp(x.^2).*((sqrt(pi)/2).*erf(x)+y0)','x','y0')
hold on;vari=0;
x=linspace(-2,2);
for y0=-2:.4:0
   vari=vari+1;
   plot(x,y(x,y0),varit(vari))
end
grid;shg;ylim([-10 10])
hold off   

%Teht. 5
clear all
f=inline('t.^2-y','t','y')

y(1)=1;
%a) 
h=0.2;n=1;x=0:h:h;
for i=1:n
   y(i+1)=y(i)+h*f(x(i),y(i));
end
plot(x,y,'r')
hold on
xya=[x' y']

clear y
y(1)=1;
%b) 
h=0.1;n=2;x=0:h:2*h;
for i=1:n
   y(i+1)=y(i)+h*f(x(i),y(i));
end
plot(x,y,'g')
xyb=[x' y']

clear y
y(1)=1;
%c) 
h=0.05;n=4;x=0:h:4*h;
for i=1:n
   y(i+1)=y(i)+h*f(x(i),y(i));
end
plot(x,y,'b')
xyc=[x' y']




