Numerical Integration -- the Left and Right Rectangle Rules and the Midpoint Rule

Let g(x) be a function defined for all x in the closed interval [a,b]. We may approximate the integral [integral of g from a to b] as follows: Divide the integration interval [a,b] into n equal pieces. Let x0 = a and x1 = a + (b-a)/n denote the endpoints of the first piece. In similar manner, the endpoints of the jth piece are xj-1 and xj , with xi = a + i*(b-a)/n for i = 0,1,..., n. The width of each piece is delta_x = (b-a)/n .

For the left rectangle rule, we approximate the function g(x) over the subinterval [xj-1 , xj] by its value at the left endpoint of that subinterval, i.e., by . This results in the approximation

[left rect. rule]

Similarly, for the right rectangle rule we approximate the function g(x) over the interval [xj-1 , xj] by , and for the midpoint rule by , where , resulting in the approximations

[right rect. rule]

and

[midpoint rule]

respectively.

[graph]  [graph]  [graph]
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.


Go back to the Electric Potential module