Originally Posted by

**lilyungn** I need help computing this integral with the different techniques mentioned below.

∫ 50 1/x dx

1

(thats a 50 at the top and a 1 at the bottom of the integram sign)

- Right rectangular scheme

- Left rectangular scheme

- Midpoint Rectangular scheme

- trapezoid scheme

- Simpson sRule

for the first 2 just use the definition of a Riemann sum.

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

Code:

function [ output ] = LeftEnd(n,a,b )
%Use Left end point to approximate the integral of 1/x from a to b using
% n points.
OneOver=@(x) x.^(-1);
v=zeros(1,n);
for m=1:n
v(1,m)=a+((b-a)/n)*((m-1));
end
y=OneOver(v);
output=((b-a)/n)*sum(y);
end