Originally Posted by

**ramdrop** Im still not really understanding it, I find MATLAB so difficult although it is a very effective tool to use.

I see what you mean by the function x² , if I was say, to use exp(x) function, The way I see it is the "up / lo" is defined as "x", so I would put in, exp(lo) and exp(up) or something?

With the actual command 'in(1,5,10)' thats integrating the function between limits 5 and 1 , subtracting the 1st limit from the 5th limit as you normally would do.

The 'n' in this case is suppose to be the number of strips, but not seeing how, or where this affects it. I know its suppose to make it more accurate or something, so Il try with say, 100 strips and see, it should ultimately get closer to the Integral.

Im also trying to, (after iv typed the command) I want it to show "Up = ...." and Lo = "....", and mathematically I work out the integral to be between, then when I up the value of 'n' the "bounds" get closer together, how would i write this?

Function definition for integrating exp(x) from a to b using n subintervals:

Code:

function [II,Lo,Up] = Riemann(a,b,n)
% integrates increasing function
h = (b-a)/n;
lo = a+h*(0:n-1);
up = lo+h;
Up = h*sum(exp(up));
Lo = h*sum(exp(lo));
II=(Up+Lo)/2;
end

Calling code and results:

Code:

>> [II,Lo,Up]=Riemann(1,5,2000)
II =
145.6949
Lo =
145.5492
Up =
145.8406
>>

Actual integral is $\displaystyle exp(5)-exp(1)=145.6949$

CB