function [pi_est, pi_error] =picalc(N)
	% pi_est  - Monte-Carlo estimate of Pi 
	% pi_error  - true error i.e. abs(pi_est-pi)


	box_side=2;
	% we will calculate area of the circle
	% enclosed in the box with the side size equal to 2
	% thus area of the box 4=2x2
	% and radius of the circle tightly enclosed equals to 1
	x=rand(1,N);
	y=rand(1,N);


	r=sqrt(x.^2+y.^2); % radius vector provided x and y coordinate

	N_enclosed=sum( r <= box_side/2); % number of points inside the circle
	% notice Matlab shortcuts
	% r <= box_side/2 returns array of true (1) and false (0)
	%       in positions of those r which inside of the circle
	% sum over that array of 1 and 0 gives us 
	%    number of points inside the circle

	box_area=box_side^2;
	pi_est=N_enclosed/N*box_area;
	pi_error=abs(pi_est-pi);
end




