RiemannSum Package

Mathematica Packages
Bruce Torrence Homepage

RiemannSum[x^2, {x, -1, 1}, Subintervals -> 15, Height -> Midpoint]
Midpoint Riemann Sum = 0.663704

- Graphics -

Synopsis

This package provides a single command to calculate and visualize a simple Riemann sum. It is intended as an instructional aid.

Command

The following command is provided in this package:

RiemannSum[f,{x,xmin,xmax,dx}] produces a graph of the function f over the interval xmin < x < xmax and includes rectangles for the Riemann sum approximation of the definite integral of f, using widths dx. Alternatively, one may use the syntax RiemannSum[f,{x,xmin,xmax},Subintervals->n] to specify that there should be n subintervals of equal width. The option Subintervals may also be set to a list of values for the endpoints of the subintervals. This allows for rectangles of unequal width. Other options include Height, which may be set to Left, Right, Midpoint (default), Upper, or Lower. RiemannSum will also return the numerical value of the approximation unless the option Printout is set to False. In the case of Upper or Lower sums, each subinterval is sampled many times to determine where the min or max occurs; the number of points sampled may be adjusted with the option ULSubdivisions. Lastly, the option RectangleStyle may be set to a Graphics directive (or list of directives) to control the appearance of the rectangles.


Last Updated: June 20, 2002