
#priklady na integraci/reseni diferencialnich rovnic
function cviceni6

#nejprve integrace

x=-10:0.1:10;

plot(x,fce1(x))
quad(@fce1,-10,10)
[integ,ier,nfun,err]=quad(@fce1,-Inf,Inf,0.1)
integ-sqrt(pi)
[integ,ier,nfun,err]=quad(@fce1,-Inf,Inf,1e-12)
integ-sqrt(pi)


#plot(x,fce2(x))
#b=linspace(0,10,300);
#for i=1:length(b)
#  res(i)=quad(@fce2,0,b(i));
#endfor
#plot(b,res)


# singularita

plot(x,fce3(x))

integ2=quad(@fce3,-1,1)
integ2-1.892166140734366


integ2=quad(@fce3,-1,1,1e-10,0)
integ2-1.892166140734366



# 2D integrace
[xx,yy]=meshgrid([0:0.02:1]);
mesh(xx,yy,fce4(xx,yy))
dblquad(@fce4,0,1,0,1)



# dif. rovnice


y0=[1;0]; #poc podminky
x=linspace(0,50,200);
res=lsode(@ode,y0,x);
plot(x,res(:,1))


endfunction





function y=fce1(x)
y=exp(-x.^2);
endfunction

function y=fce2(x)
y=cos(x.^2);
endfunction

function y=fce3(x)
y=sin(x)./x;
endfunction

function y=fce4(x,y)
  y=sin(pi*x.*y).*sqrt(x.*y);
endfunction

function ydot=ode(y,x)
  ydot(1)=y(2);
  ydot(2)=-y(1)-0.2*y(2);
endfunction


