Let
be a function defined for
all x in the closed interval
as follows:
Divide the integration interval
= (b-a)/n .
For the left rectangle rule, we approximate the function
over the subinterval
.
This results in the approximation
Similarly, for the right rectangle rule we approximate the function
over the interval
,
and for the midpoint rule by
, where
,
resulting in the approximations
|
|
![]() |
| Left Rectangle Rule | Right Rectangle Rule | Midpoint Rule |
The formulas look very similar, and require about the same amount of coding and computation. But it can be shown that, for most cases, the midpoint rule formula yields a more accurate approximation than the other two rules (for a given n) and hence is the method of choice among these three.
If your browser is Java-capable, check out this applet which graphically illustrates left and right rectangle rules, and also evaluates the approximations resulting from the application of these rules (click on "Show Riemann sum" in the applet window to activate this feature). Note that you define the function to be plotted and integrated; be sure the variable you use in your definition is x.
Here is another applet which illustrates three numerical integration methods (including the right rectangle rule, which is simply called "Rectangular", and the midpoint rule) for several pre-defined functions.