function approx_int = opt_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;
mid_points = 0.5*(xvals(1:end-1) + xvals(2:end));
approx_int = sum(feval(f,mid_points)*delta_x);
end
