disp(' ')
disp(' pi_gpi.m  ver 1.0  November 30, 2009 ');
disp(' by Tom Irvine  Email: tomirvine@aol.com');
disp(' ');
disp(' Calculate pi using simple grid point integration. ');
disp(' ');
N=input(' Enter the number of grid points per axis ');
n=0;
disp(' ');
progressbar % Create figure and set starting time
%
N=N-1;
for(i=0:N)
    x=double(i)/N;
    progressbar(i/N) % Update figure      
    for(j=0:N)
        y=double(j)/N;
        yL=sqrt(1-(x^2));
        if(y<=yL)
            n=n+1;
        end
    end
end
k=(N+1)^2;
%
area=4*double(n)/double(k);
pia=area;
disp(' ');
out1=sprintf('Total grid points=%10.6g  pi=%10.8f ',k,pia);
disp(out1);