I'm trying to write a program using the Manipulate
function that shows the leftmost, rightmost, and midpoint Riemann sums for a function. I've successfully coded the graphs for each one, however I'm not sure how to apply the Manipulate
function to it. Here are the graphs I've coded:
f[x_] := 3 x^2 + 5
rectangles =
Module[{low, high, squarenum, delta, fright, fleft, fmid, curve1},
low = 0; high = 2;
squarenum = 4;
delta = (high - low)/squarenum;
fright =
Graphics[{FaceForm[{Opacity[0.7]}],
Table[{Hue[0.79, 0.92, 0.88], EdgeForm[Thin],
Rectangle[{low + (n - 1)*delta, 0}, {low + n*delta,
f[low + n*delta]}]}, {n, 1, squarenum} ]}, ImageSize -> 50];
fleft = Graphics[{FaceForm[{Opacity[0.7]}],
Table[{Hue[0.79, 0.92, 0.88], EdgeForm[Thin],
Rectangle[{low + n*delta, 0}, {low + (n + 1)*delta,
f[low + n*delta]}]}, {n, 1, squarenum} ]}, ImageSize -> 62];
fmid = Graphics[{FaceForm[{Opacity[0.7]}],
Table[{Hue[0.79, 0.92, 0.88], EdgeForm[Thin],
Rectangle[{low + (n - 0.5)*delta,
0}, {(low) + (n + 0.5)*(delta), f[low + n*delta]}]}, {n, 1,
squarenum} ]}, ImageSize -> 56];
curve1 =
Plot[f[x], {x, low, high}, PlotStyle -> Thick, ImageSize -> 200];
Show[{fright, curve1}] Show[{fleft, curve1}] Show[{fmid, curve1}]]
Any help would be appreciated, I've been racking my brain and have been stuck for hours