Computing Integrals Numerically
Many definite integrals have no closed-form antiderivative — (the Gaussian) is the famous example. When the Fundamental Theorem cannot be applied, numerical integration (quadrature) approximates the integral directly from function values, refining the Riemann-sum idea of Unit 6.
The methods approximate the area under the curve with simple shapes on each subinterval:
- Rectangle (midpoint) rule — approximate each strip by a rectangle. Crude, error per the step size .
- Trapezoidal rule — approximate each strip by a trapezoid (connect adjacent points with a straight line), averaging the two endpoint heights. Better than rectangles; error overall but with a smaller constant.
- Simpson's rule — fit a parabola through each triple of points instead of a straight line. Because parabolas hug curves far better than lines, Simpson's is dramatically more accurate: its error is , so halving the step size cuts the error by sixteen, not four.
The overarching principle: finer subdivisions (smaller ) give more accuracy, and higher-order rules (fitting richer shapes) converge faster still. Simpson's rule is exact for polynomials up to degree three, which is why it excels on smooth functions.
The subtlety that reconnects to Lesson 2: you cannot make arbitrarily small in search of perfect accuracy. Shrinking reduces the method's (truncation) error, but very small means summing very many tiny terms, so accumulated round-off error eventually grows. There is an optimal subdivision, and a good rule (like Simpson's) reaches high accuracy at a modest , avoiding the round-off regime. Numerical integration is a workhorse across physics, statistics (integrating probability densities), and engineering.
Common pitfall: assuming that more subdivisions always give a better answer, without limit. A smaller step size reduces the truncation error of the rule, but summing ever more tiny contributions eventually lets round-off error accumulate and dominate — so accuracy improves only up to an optimal . Using a higher-order rule (Simpson's over trapezoidal) is usually the better path to accuracy than blindly shrinking .