format compact
numpoints = 100 % number of random points
sum = 0; % initialize variable
for index = 1:numpoints, % Create a loop
   xvalue = rand; % Choose a random number
   integrand = sqrt(1-xvalue^2); % Evaluate the integrand
   sum = sum + integrand; % Sum the integrand for all random points
end
   format long
   integral = sum/numpoints % Monte-Carlo value of the integral
   pi_approx = 4*integral % Monte-Carlo value of pi
   pi_true = pi % Actual value of pi
   format short
   pi_fractional_error = (pi-pi_approx)/pi % fractional error of approximation