Advertisement
Guest User

Untitled

a guest
Jul 3rd, 2015
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. LRiemann[f_, {a_, b_, n_}] := Module[
  2. {dx, i, c, rect, plot, sum},
  3. dx = N[(b - a)/n];
  4. c = Table[a + i*dx, {i, 0, n}];
  5. rect = Table[
  6. Rectangle[ { c[[i]], 0}, {c[[i + 1]], f[c[[i]]] } ] , {i,
  7. 1, n} ];
  8. plot =
  9. Plot[f[x], {x, a, b}, AxesOrigin -> {0, 0},
  10. PlotLabel ->
  11. Style[f[x] sum "-> Aprox. Area of f(x) = ", FontSize -> 15],
  12. PlotRange -> All, PlotStyle -> Directive[Thick, Black]];
  13. sum = dx*Sum[f[a + (j - 1)*dx], {j, 1, n}];
  14. Show[
  15. plot,
  16. Graphics[{RGBColor[166/255, 206/255, 227/255],
  17. EdgeForm[Directive[Thin, RGBColor[31/255, 120/255, 180/255]]],
  18. Opacity[0.5], rect}]
  19. ]
  20. ]
  21. f[x_] := x*Sin[x];
  22. Animate[
  23. LRiemann[f, {-3 Pi, 3 Pi, n}] , {n, 1, 60},
  24. AnimationRunning -> False ]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement