function totalpi = calcPiSerial(npts)
% CALCPISERIAL
% Approximates the integral of 4/(1+x*x) between 0 and 1
if nargin==0, npts = 4; end
% Set up step size based on number of points
h = 1/npts;
% Initialize variable of integral
mysum = 0;
% Obtain cumlative sum of points
for index = 1:npts
x = h * (index - 0.5);
mysum = mysum + 4 / (1 + x*x);
end
% Multiply by step size to get area under the curve
totalpi = h * mysum;