📊 Section 1 -- Interactive Simulation
Controls
Function & Rule
Display
💡 Section 2 -- The Idea, Step by Step
One idea — adding up many thin rectangles — is the whole engine behind the definite integral. Here it is, built from a playground picture all the way up to the calculus statement.
Suppose you want the area of a hill whose top is a curve. You can't just do length × width, because the top isn't flat. So cover the region with thin vertical strips, like floor tiles stood on end. Each tile is a skinny rectangle, and rectangles are easy: area = height × width. Add up every tile and you get a close estimate of the curvy area. Make the tiles thinner and the estimate gets better.
Slice the interval $[a,b]$ into $n$ equal strips. Each strip has width $\Delta x=\frac{b-a}{n}$, and its height is the function value $f(x_i)$ at a sample point inside the strip. One strip's area is $f(x_i)\,\Delta x$, so the whole estimate is the Riemann sum $S_n=\sum_{i=1}^{n} f(x_i)\,\Delta x$. For $f(x)=x^2$ on $[0,1]$ with $n=4$ left-corner samples, $S_4=0.25\,(0+0.0625+0.25+0.5625)=0.219$ — already close to the true area $\tfrac13\approx0.333$.
Now let $n\to\infty$, so $\Delta x\to0$. The staircase of rectangles presses onto the curve and $S_n$ settles on a single number — the definite integral $\int_a^b f(x)\,dx$. For a continuous $f$ it doesn't matter whether you sample each strip on the left, right, or middle: every choice shares the same limit. The choices differ only in speed. Left and right corners trail the answer like $O(h)$, midpoint and trapezoid like $O(h^2)$, and Simpson's little parabolas like $O(h^4)$ — so each halving of the strip width shrinks Simpson's error roughly 16×.
Set Rule = Left and drag n from 2 to 100 — watch $S_n$ climb toward $0.3333$ while $|\text{Error}|$ collapses. Switch Rule = Simpson at $n=4$: its error is already about $10^{-5}$, far below Left at the same $n$. Then open the Error Rates tab to see each rule as a straight line on log-log axes — the steeper the line, the faster it converges, and Simpson's is steepest.
📐 Section 3 -- Riemann Sums
$$\int_a^b f(x)\,dx=\lim_{n\to\infty}\sum_{i=1}^n f(x_i^*)\,\Delta x,\quad \Delta x=\frac{b-a}{n}.$$
| Rule | Formula | Error order |
|---|---|---|
| Left | $\sum f(x_{i-1})\,\Delta x$ | $O(h)$ |
| Midpoint | $\sum f(x_{i-1/2})\,\Delta x$ | $O(h^2)$ |
| Trapezoidal | $\frac{h}{2}[f_0+2f_1+\cdots+f_n]$ | $O(h^2)$ |
| Simpson | $\frac{h}{3}[f_0+4f_1+2f_2+\cdots+f_n]$ | $O(h^4)$ |
Partition $[a,b]$: $a=x_0<\cdots
Linear interpolation on each subinterval: $T_n=h/2[f_0+2f_1+\cdots+2f_{n-1}+f_n]$. Error bound: $|E_T|\leq M_2(b-a)^3/(12n^2)$.
Quadratic fit per pair of intervals (n must be even): $S_n=h/3[f_0+4f_1+2f_2+4f_3+\cdots+f_n]$. Error $O(h^4)$ -- exact for polynomials up to degree 3.
Simpson n=2: h=0.5, f_0=0, f_1=0.25, f_2=1. $S=(0.5/3)[0+4(0.25)+1]=1/3$ exactly. Simpson is exact for quadratics since error involves $f^{(4)}=0$.
Every continuous function is Riemann integrable. Every monotone bounded function is integrable. NOT integrable: Dirichlet function (1 on rationals, 0 on irrationals). Lebesgue integral handles this general case.
By MVT: $F(x_i)-F(x_{i-1})=f(c_i)\Delta x$. Summing: $F(b)-F(a)=\sum f(c_i)\Delta x$ -- a Riemann sum. As $n\to\infty$: $F(b)-F(a)=\int_a^b f(x)\,dx$.
❓ Section 4 -- FAQ
Each rectangle has width Delta-x and height f(x_i*). Its area approximates the signed area under the curve on that subinterval. As n increases, the rectangles become thinner and the total area converges to the integral.
Key takeaway: Each rectangle area = f(xi)*Delta_x. Sum approximates signed area under curve.Four rules plotted as |error| vs n on log-log axes. Left/Right: slope 1 (O(h)). Midpoint/Trap: slope 2 (O(h^2)). Simpson: slope 4 (O(h^4)). Steeper slope = faster convergence. Doubling n: Simpson error shrinks by factor 16.
Key takeaway: Slope on log-log error plot = convergence order. Simpson slope 4 is far better than Left slope 1.Finite element analysis (structural engineering). Monte Carlo integration for high-dimensional probability in ML. Computer graphics: light transport path integrals. Quantum chemistry: electron orbital calculations. GPS satellite orbit prediction.
Key takeaway: FEM, Monte Carlo ML, light transport, quantum chemistry -- all numerical integration.Yes. The error per Simpson panel is O(h^5), giving O(h^4) globally. The error involves the 4th derivative -- zero for cubics. This superconvergence makes Simpson dramatically better than trapezoidal for smooth functions.
Key takeaway: Simpson integrates cubics exactly because error involves f^(4) = 0 for polynomials of degree <= 3.h=0.25. S=(0.25/3)[1 + 4*e^0.25 + 2*e^0.5 + 4*e^0.75 + e] = (0.25/3)*20.620 = 1.71832. Exact: e-1=1.71828. Error~4e-5. Left Riemann n=4 gives ~1.512 with error~0.206. Simpson is ~5500x more accurate.
Key takeaway: Simpson n=4 error ~4e-5. Left n=4 error ~0.21. Factor of ~5500 improvement from 4 subintervals.Riemann partitions the x-axis. Lebesgue partitions the y-axis (values of f): int f d_mu = int_0^inf mu({f>t}) dt (layer-cake). Integrates more functions, has stronger limit theorems (dominated convergence), and works on abstract measure spaces. Foundation of modern probability theory.
Key takeaway: Lebesgue partitions y-axis, integrates more functions, has better limit theorems. Basis of probability theory.