Why numeric integration exists at all
A definite integral ∫ f(x) dx from a to b computes the exact signed area under a curve — and for many functions, a symbolic antiderivative exists, letting you evaluate it exactly. But plenty of real, well-behaved functions (including sin(x)/x, e^(-x²), and many others that show up constantly in statistics and physics) have no elementary closed-form antiderivative at all — not because nobody's found it, but because it provably doesn't exist in terms of standard functions. Numeric integration sidesteps this entirely: it approximates the area using only function evaluations, never requiring an antiderivative to exist.
The basic idea: approximate with simpler shapes
The simplest numeric approach — the rectangle method — divides [a, b] into strips and approximates each strip's area as a rectangle. This is crude and requires very many strips for good accuracy. The trapezoidal rule improves this using trapezoids instead of rectangles. Simpson's rule goes one step further: it approximates the function with a parabola across each pair of intervals, which fits smooth curves far more accurately than a straight-line trapezoid for the same number of evaluation points.
The formula, and why it alternates coefficients
Composite Simpson's rule with n intervals (n must be even) computes:
∫ f(x) dx ≈ (h/3) × [f(x₀) + 4f(x₁) + 2f(x₂) + 4f(x₃) + ... + 4f(x_{n-1}) + f(xₙ)]
where h = (b-a)/n. The alternating 4, 2, 4, 2... pattern comes directly from fitting a parabola through each set of three consecutive points and integrating that parabola exactly — the endpoints of each parabolic segment get weight 4 (odd-indexed points) or 2 (even-indexed, shared between adjacent segments), and the two outermost endpoints get weight 1.
Why Simpson's rule converges so much faster than simpler methods
For a smooth function, Simpson's rule's error shrinks proportionally to h⁴ (the interval width raised to the fourth power), while the trapezoidal rule's error only shrinks proportionally to h². Halving the interval width roughly divides Simpson's rule's error by 16, versus only by 4 for the trapezoidal rule — which is why Simpson's rule reaches very high accuracy (often 6+ correct decimal digits) with a modest number of intervals, rather than requiring an enormous number of tiny slices.
Where numeric integration still has limits
- Discontinuities or singularities inside the interval (a function that's undefined or has a sharp jump somewhere between
aandb) break the smooth-curve assumption Simpson's rule relies on, and can produce a meaningfully wrong result without an explicit error. - Rapidly oscillating functions relative to the chosen interval width can be under-sampled, missing oscillations entirely between evaluation points.
- Improper integrals (an infinite bound, or a function that blows up right at an endpoint) need special handling — a fixed-interval method like plain Simpson's rule doesn't directly handle an infinite range.
Common mistakes
- Assuming numeric integration is always exact. It's an approximation — extremely accurate for smooth functions with enough intervals, but still fundamentally distinct from a symbolic exact answer.
- Not checking for discontinuities in the integration range beforehand. A function undefined at some point strictly between
aandbcan silently produce a misleading numeric result if that specific point isn't sampled directly. - Assuming more intervals always help unboundedly. Beyond a certain point, floating-point rounding error in the accumulated sum becomes the dominant error source, not the method's own approximation error.
FAQ
Why doesn't every function have a symbolic antiderivative?
Some functions, though perfectly well-defined and continuous, provably cannot be expressed as a combination of elementary functions (polynomials, trig, exponentials, logs) after integration — this is a proven mathematical fact for certain functions, not a gap in current knowledge.
Why is Simpson's rule more accurate than the trapezoidal rule for the same number of points?
It fits a parabola through each set of points instead of a straight line, capturing curvature that a trapezoid's flat top misses — its error shrinks with the fourth power of interval width, versus the trapezoidal rule's second power.
Can numeric integration handle a function with a discontinuity in the integration range?
Not reliably with a basic fixed-interval method — a jump or undefined point inside the range violates the smoothness assumption the approximation relies on, and can produce an inaccurate result without any explicit warning.
Approximate any definite integral instantly with the Definite Integral Calculator — computed entirely in your browser using composite Simpson's rule.