Riemann sums

Level FundamentalDifficulty ★★★★★Concept⌖ Open in the map

What is it?

Approximate the area under a curve by nn thin rectangles, ∑f(xi∗) Δx\sum f(x_i^\ast)\,\Delta x. As n→∞n \to \infty the sum converges to the integral — slowly for the left/right rule (O(1/n)O(1/n)), faster for the midpoint (O(1/n2)O(1/n^2)).

Formulas

Sn=∑i=1nf(xi∗) Δx,Δx=b−an,xi∗∈[xi−1,xi]S_n = \sum_{i=1}^{n} f(x_i^\ast)\,\Delta x, \qquad \Delta x = \frac{b - a}{n}, \quad x_i^\ast \in [x_{i-1}, x_i]

Interactive visualization

Increase n and watch the sum converge to the area. Left and right sums have error ∝ 1/n; midpoint and trapezoid ∝ 1/n².

Where it shows up in computing

  • Monte Carlo methods★★★★★frequentScientific computing and algorithms

    Monte Carlo integration is a Riemann-like sum with random sample points instead of a grid.

Where is it used?

Computing topics reachable from here, through the chain of ideas that leads to them:

What depends on it

Exercises

1Graphical

In the demo, compare the left and midpoint sums for sin⁡x\sin x on [0,π][0,\pi] with n=10n = 10. Why is the midpoint so much better?

Solution

On each strip the midpoint rectangle over- and under-estimates by nearly equal amounts on the two halves, so the first-order errors cancel and only a curvature term O(Δx3)O(\Delta x^3) per strip survives: total O(1/n2)O(1/n^2) instead of O(1/n)O(1/n).

This page has the essentials. A fuller treatment (intuition, formal definition, worked example) is on the way.

↑ ↓ to navigate · ↵ · Esc