% Integrazione MC
clear;
xmin=0;
xmax=pi/2;
nbin=1000;
dx=(xmax-xmin)/nbin
x=xmin:dx:xmax;
y=sin(1./(x+dx/2).^2);
plot(x,y,'-r')
imax=1000;
t=cputime;
for k=1:2
    imx=k*imax
	r=rand(imx,1)*(xmax-xmin)+xmin;
	integral(k)=sum(sin(1./(r.^2)))*(xmax-xmin)/imx;
end
prec=abs(integral(1)-integral(2))/integral(2)
et=cputime-t
