Replies To: Python program to evaluate a Riemann sum?

Re: Python program to evaluate a Riemann sum?

Posted 04 September 2007 - 09:13 PM

Your teacher has actually asked you to do something a little abstract so you should start by making some decisions.
How many intervals will you use?
Where will you choose your x* from (first point in interval, mid-point, last point (usually the "Riemann sum" refers to a point inside the interval so the mid-point is often easiest)?
Break up the intervals evenly?

Once you have made such choices... choose the points in the interval (a, and then calculate y(xi) for each of these points. If you have made the intervals evenly broken up (so dx = (b - a)/n where n = number of intervals) then you can sum up the areas dx*y(xi).

I am no Python expert, so I would just use simple loops and linear interpolation myself.