- #1
jcharles513
- 22
- 0
Homework Statement
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]]]
Homework Equations
Knowledge about right and left riemann sums is necessary. Also partitions of the rectangles is (b-a/n).
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.