disp(' ')
disp(' pi_gpi.m  ver 1.0  November 30, 2009 ');
disp(' by Tom Irvine  Email: tomirvine@aol.com');
disp(' ');
disp(' Calculate pi using the arclength ');
disp(' ');
N=input(' Enter the number of points ');
disp(' ');
%
sum=0;
x1=0;
y1=0.5;
%    
progressbar % Create figure and set starting time
%    
for(i=1:N)
    progressbar(i/N) % Update figure     
    x2=0.5*double(i)/double(N);
    y2=sqrt(0.25-x2^2);
    d=sqrt( (x2-x1)^2 +(y2-y1)^2 );
    sum=sum+d;
    x1=x2;
    y1=y2;
end
disp(' ');
out1=sprintf(' pi=%10.8f ',4*sum);
disp(out1);