In the rectangle method, the function to integrate \( f \) is replaced by a piecewise constant function \( g(x) \) on each elementary interval \([x_{i-1}, x_i]\):
- Left rectangles: \( g(x) = f(x_{i-1}) \) for \( x \in [x_{i-1}, x_i] \)
- Right rectangles: \( g(x) = f(x_i) \) for \( x \in [x_{i-1}, x_i] \)
- Midpoint rectangles: \( g(x) = f\left(\frac{x_{i-1}+x_i}{2}\right) \) for \( x \in [x_{i-1}, x_i] \)
The associated integration formulas are:
Left rectangles: ∫ab f(x) dx ≈ Σi=1n (x_i - x_{i-1}) f(x_{i-1})
Right rectangles: ∫ab f(x) dx ≈ Σi=1n (x_i - x_{i-1}) f(x_i)
Midpoint rectangles: ∫ab f(x) dx ≈ Σi=1n (x_i - x_{i-1}) f((x_{i-1}+x_i)/2)
If the subdivision is uniform with step \( h = \frac{b-a}{n} \), then:
Left rectangles: ∫ab f(x) dx ≈ h Σi=0n-1 f(x_i)
Right rectangles: ∫ab f(x) dx ≈ h Σi=1n f(x_i)
Midpoint rectangles: ∫ab f(x) dx ≈ h Σi=1n f((x_{i-1}+x_i)/2)
Error
The left and right rectangle methods are order 0. If the first derivative of \( f \) is bounded by \( M \):
Left rectangles: | ∫ab f(x) dx - h Σi=0n-1 f(x_i) | ≤ (b-a)/2 × h × sup |f'(x)|
Right rectangles: | ∫ab f(x) dx - h Σi=1n f(x_i) | ≤ (b-a)/2 × h × sup |f'(x)|
The midpoint rectangle method is order 1. If \( f \in C^2([a,b]) \):
| ∫ab f(x) dx - h Σi=1n f((x_{i-1}+x_i)/2) | ≤ (b-a)/24 × h² × sup |f''(x)|
Numerical Example
Evaluate numerically ∫02 sin(x) dx with n=3 (h=2/3):
| i | x_i | f(x_i) = sin(x_i) |
|---|---|---|
| 0 | 0 | 0 |
| 1 | 2/3 | ≈ 0.6184 |
| 2 | 4/3 | ≈ 0.9705 |
| 3 | 2 | ≈ 0.9093 |
Midpoints:
| i | (x_{i-1}+x_i)/2 | f(midpoint) |
|---|---|---|
| 1 | 1/3 | ≈ 0.3270 |
| 2 | 1 | ≈ 0.8415 |
| 3 | 5/3 | ≈ 0.9950 |
Results:
- Left rectangles: Rg = (2/3)(0 + 0.6184 + 0.9705) ≈ 1.0586
- Right rectangles: Rd = (2/3)(0.6184 + 0.9705 + 0.9093) ≈ 1.6646
- Midpoint rectangles: Rm = (2/3)(0.3270 + 0.8415 + 0.9950) ≈ 1.5410
The exact integral is I(f) = 1 − cos(2) ≈ 1.4161. Relative errors are:
- Error(Rg) = |1.4161 − 1.0586| ≈ 0.3575 → 25.23%
- Error(Rd) = |1.6646 − 1.4161| ≈ 0.2485 → 17.55%
- Error(Rm) = |1.5410 − 1.4161| ≈ 0.1249 → 8.82%