for the first 2 just use the definition of a Riemann sum.
Originally Posted by lilyungn
Here is some pseudo code
if you want left end points and for right
Now for the left just calculate
In Matlab would use parameters like a and b and have the function take them as an input. Also if you define your partition as a vector you can have Matlab evaluate all of the 's at the same time. Just modify the above to use the other quadrature rules.
Here is a copy of an m file for the left end point
function [ output ] = LeftEnd(n,a,b )
%Use Left end point to approximate the integral of 1/x from a to b using
% n points.