Mathematica 9 is now available
Student Support Forum
Student Support Forum: 'Left and Right Riemann Sums' topicStudent Support Forum > General > Archives > "Left and Right Riemann Sums"

Help | Reply To Topic
Author Comment/Response
James C.
01/28/09 12:53pm

1. The problem statement, all variables and given/known data
I am given a left riemann sum program module in Mathematica and need to convert it into the right riemann sum. The program takes values for x and f/x and the partition and graphs on a certain interval provided.

leftRiemannGraph[f_, a_, b_, n_] := Module[{expr},
expr[1] =
Table[{{x, f[x]}, {x + (b - a)/n, f[x]}}, {x, a, b, (b - a)/n}];
expr[2] = Flatten[expr[1], 1];
expr[3] = Drop[expr[2], -2];
plt[1] = ListLinePlot[expr[3], Filling -> Axis];
plt[2] = Plot[f[x], {x, a, b}];
Show[plt[1], plt[2]]]

2. Relevant equations
Knowledge about right and left riemann sums is necessary. Also partitions of the rectangles is (b-a/n).

3. The attempt at a solution
I attempted this problem for several hours. The only thing I really figured out is that expr[3]=Drop[expr[2],-2]; needs to be changed to expr[3]=Drop[expr[2],2]; to drop the first 2 not the last two. Also I know that the 3rd line is the one that needs changed. I'm just not sure what needs to be changed on it, in order to graph the right riemann sum. This has been racking my brain for the last week. Please help.

URL: ,
Help | Reply To Topic