Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- LRiemann[f_, {a_, b_, n_}] := Module[
- {dx, i, c, rect, plot, sum},
- dx = N[(b - a)/n];
- c = Table[a + i*dx, {i, 0, n}];
- rect = Table[
- Rectangle[ { c[[i]], 0}, {c[[i + 1]], f[c[[i]]] } ] , {i,
- 1, n} ];
- plot =
- Plot[f[x], {x, a, b}, AxesOrigin -> {0, 0},
- PlotLabel ->
- Style[f[x] sum "-> Aprox. Area of f(x) = ", FontSize -> 15],
- PlotRange -> All, PlotStyle -> Directive[Thick, Black]];
- sum = dx*Sum[f[a + (j - 1)*dx], {j, 1, n}];
- Show[
- plot,
- Graphics[{RGBColor[166/255, 206/255, 227/255],
- EdgeForm[Directive[Thin, RGBColor[31/255, 120/255, 180/255]]],
- Opacity[0.5], rect}]
- ]
- ]
- f[x_] := x*Sin[x];
- Animate[
- LRiemann[f, {-3 Pi, 3 Pi, n}] , {n, 1, 60},
- AnimationRunning -> False ]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement