function approx_int = mid_point_method(f,a,b,n)
%approximates approximate integral using midpoint method

%generate points for subintervals
xvals = linspace(a,b,n+1);
delta_x = (b-a)/n;

rsum=0;

for i=1:n
    xmid = 0.5*(xvals(i+1) + xvals(i));
    rsum = rsum+feval(f,xmid)*delta_x;
end
approx_int = rsum;

end