The one idea behind every rule: replace, then integrate exactly
You want the definite integral of f from a to b — the signed area under the curve. The honest obstacle is that a computer almost never has a formula for f; it has only sampled values, f at a grid of points, the way a thermometer gives you readings but not a temperature function. So we cannot integrate f itself. The whole game of numerical integration, or quadrature for short, is to replace the unknown curve with a stand-in we can integrate by hand, and then return the area of the stand-in.
What makes a good stand-in? A shape that is both flexible enough to hug the real curve and simple enough to integrate in closed form. Polynomials are the obvious answer: they bend, yet the area under a polynomial is trivial calculus. So the recipe becomes — fit a low-degree interpolating polynomial through your sampled points, integrate that polynomial exactly, and call the result your approximate integral. Every classical rule in this guide is just this recipe with a different polynomial degree.
This is the same move you saw with finite differences earlier in this rung, but read in the other direction. There you replaced f locally by a low-degree polynomial and differentiated it to get a derivative formula; here you replace f by a polynomial and integrate it to get an area formula. Differentiation and integration are the two ways to milk one interpolating polynomial. That shared root is why both families carry the same kind of error term — a power of the step size h — and why the trick you are about to learn, halving h and combining, works for both.
The trapezoidal rule: a straight line is the simplest stand-in
Start with the humblest polynomial: degree one, a straight line. Sample f only at the two endpoints, a and b, draw the straight chord between f(a) and f(b), and the area under that chord is a trapezoid. Its area is the width times the average of the two heights. That is the entire trapezoidal rule: integral ≈ (b - a) * (f(a) + f(b)) / 2. Picture it literally — you are roofing the region with a single slanted plank and reading off the area underneath.
Of course one giant trapezoid over a wildly bending curve is hopeless. The fix is obvious and is the workhorse of all of numerical integration: chop [a, b] into n thin strips of width h = (b - a)/n, lay a small trapezoid over each strip, and add them up. This is the composite trapezoidal rule. Because neighbouring strips share an endpoint, the bookkeeping collapses to a tidy sum: every interior sample is counted once with full weight, the two ends with half weight, all times h.
Composite trapezoidal rule on [a, b] with n strips, h = (b - a)/n:
integral ~= h * [ f(a)/2 + f(x_1) + f(x_2) + ... + f(x_{n-1}) + f(b)/2 ]
where x_k = a + k*h.
Error shrinks like O(h^2): halve h -> error drops by about 4x.How wrong is it? A careful expansion of the error (the same Taylor-series machinery behind the finite-difference formulas) shows the composite trapezoidal error behaves like O(h^2) and is proportional to f''(x): it is exactly the curve's curvature you are paying for, because a straight chord cannot follow a bending curve. The headline consequence is the one to memorise — halve the step h and the error drops by a factor of about 4, since (1/2)^2 = 1/4. Honestly, this is slow: to gain one extra decimal digit you need roughly three times as many points. A flat or gently sloped function is integrated almost perfectly; a sharply curving one demands many strips.
Simpson's rule: let the stand-in bend
A straight chord cannot curve, so it always misses a bending function on the same side strip after strip. The natural upgrade is to let the stand-in bend too: fit a parabola — a degree-two polynomial — instead of a line. A parabola needs three points, so take the two endpoints plus the midpoint of the strip, fit the unique parabola through them, and integrate that exactly. Carrying out the algebra gives a startlingly clean weighting, the famous Simpson's rule: integral over a panel ≈ (h/3) * (f_left + 4*f_middle + f_right). The midpoint gets four times the weight of the ends — that lopsided 1-4-1 pattern is the whole rule.
Here is the delightful surprise that makes Simpson the default everyday rule. You built it to be exact for parabolas (degree two), and it is — but it turns out to be exact for cubics (degree three) as well, completely for free. The reason is symmetry: the error a cubic makes on the left half of a panel exactly cancels the error it makes on the right half. So you paid for degree two and got degree three. This bonus is the very first whisper of a deeper theme — that the placement of points, not just their number, controls how high a degree you nail — which the next guide on Gaussian quadrature turns into a full method.
The payoff in accuracy is large. Composite Simpson's error behaves like O(h^4) and is proportional to the fourth derivative f''''(x), versus O(h^2) for the trapezoidal rule. In plain terms: halve the step and the error drops by a factor of about 16, not 4. That extra speed is essentially free — Simpson reuses the very same endpoint samples, just rearranged with the 1-4-1 weights — which is why, when in doubt with a smooth function, Simpson is the sensible first reach.
Newton-Cotes: the family, and why you stop early
Trapezoidal and Simpson are the first two members of one family. Take n+1 equally spaced points across the interval, fit the unique degree-n interpolating polynomial through them, integrate it exactly, and you get the n-th Newton-Cotes rule. Degree one is trapezoidal, degree two is Simpson, degree three is the '3/8 rule', and so on. Each step up bends the stand-in more, and on a smooth function each typically buys you more accuracy. So why not just crank the degree to 20 and integrate in one shot?
Because high-degree Newton-Cotes is a trap, and the reason is one you met in the interpolation rung. Forcing a single high-degree polynomial through many equally spaced points triggers Runge's phenomenon: the polynomial develops violent oscillations near the ends of the interval, swinging far above and below the true curve no matter how many points you add. The interpolant gets worse, not better. Worse still, from about degree 8 onward the Newton-Cotes weights themselves turn negative and grow large, and large mixed-sign weights mean catastrophic cancellation in finite precision — you are subtracting big numbers to recover a small area, exactly the round-off disaster this whole ladder warns against.
So the practical wisdom is the opposite of 'higher is better': keep the degree low — trapezoidal or Simpson — and gain accuracy by using more panels of that low degree, i.e. the composite rules. Low degree dodges Runge entirely and keeps the weights positive and well-behaved. Raising the degree is the road that fails; shrinking h is the road that works. (The third escape, used by Clenshaw-Curtis and by the next guide's Gaussian quadrature, is to keep high degree but move the points off the equispaced grid — but that is a story for later.)
Romberg: turning the error formula into free accuracy
Here is where the previous guide pays off spectacularly. The composite trapezoidal error is not just 'O(h^2)' — its full expansion is a clean series in even powers of h: error = c_2*h^2 + c_4*h^4 + c_6*h^6 + ... with the coefficients independent of h. A series in known powers of h with unknown coefficients is precisely the setup Richardson extrapolation devours. Compute the trapezoidal estimate at step h and again at step h/2, then form the specific combination that annihilates the leading h^2 term — and what is left is accurate to O(h^4).
But the leftover O(h^4) estimate has its own error series in powers of h, so you can Richardson-extrapolate again to kill the h^4 term and reach O(h^6), and again, and again. Arranging these repeated extrapolations into a triangular table is Romberg integration: the first column is plain trapezoidal estimates at h, h/2, h/4, ...; each rightward column applies one more Richardson step, and the bottom-right corner is a high-order answer squeezed out of nothing but trapezoidal evaluations. Remarkably, the second column of the Romberg table is exactly Simpson's rule — Simpson is just one Richardson step applied to the trapezoidal rule, which is why its order jumped from 2 to 4.
Honest limits: error you cannot see, and dimensions you cannot reach
Two honest cautions keep these tidy rules from being oversold. First, the same round-off-versus-truncation tension you met for derivatives lurks here too, though it bites far more gently. The truncation error (the O(h^2) or O(h^4) story) shrinks as you add panels, but each new sample contributes its own rounding error, and summing millions of terms slowly accumulates floating-point noise — addition is not associative, so the order of summation even matters. Unlike numerical differentiation, integration does not divide by a tiny h, so it has no sharp round-off cliff; still, a stable summation (Kahan-style) is worth it when you are adding a vast number of strips.
Second, and far more deadly: everything here lives in one dimension. The instinct to integrate over a square by laying a grid and applying Simpson in each direction works — but a grid of m points per axis costs m^d total points in d dimensions. This is the curse of dimensionality: to integrate over a 10-dimensional region with a mere 10 points per axis is already 10^10 evaluations, and a respectable 100 points per axis is 100^10 = 10^20, utterly hopeless. Grid-based Newton-Cotes is wonderful in 1D, fine in 2D and 3D, and dead by about dimension 5 or 6.
That wall is exactly why a completely different philosophy — Monte Carlo integration — exists, and why it is not just a cruder fallback. Its error falls only like O(1/sqrt(N)), painfully slow in 1D where Simpson crushes it, but that rate is independent of dimension. In a thousand dimensions Monte Carlo simply does not care, while every grid rule is long dead. So the lesson is not 'Simpson is best' but 'match the tool to the dimension': low-degree composite rules and Romberg for smooth low-dimensional integrals, Gaussian quadrature (next guide) when you can choose your points, and random sampling once the dimension climbs out of reach.