Numerical integration
Not every integral has a closed-form antiderivative, and in engineering practice most integrals arrive as tabulated data from sensors or experiments rather than as formulas at all. Numerical integration — also called numerical quadrature — approximates using only a finite set of function values, turning an analytic problem into arithmetic on a table. This topic follows finite differences and interpolation in the Numerical Analysis block of MA10002: both standard rules covered here are, underneath, exact integrals of a piecewise polynomial fitted through the tabulated points. The trapezoidal rule fits straight lines; Simpson's rule fits parabolas. Knowing which to use, when each applies, and how to bound the error is the practical skill this article builds.
Approximate by replacing with a piecewise polynomial through equally spaced tabulated points and integrating that polynomial exactly — a straight line per panel gives the trapezoidal rule, a parabola per pair of panels gives Simpson's rule, and the parabola is more accurate for the same spacing.
The core idea
Divide into equal subintervals of width , with nodes and function values . Both rules replace the unknown curve on small pieces of by a polynomial that agrees with at the tabulated nodes, then integrate that polynomial exactly — the arithmetic below is just the result of doing that integration once and for all, so it never has to be repeated by hand.
Trapezoidal rule. On each subinterval , is replaced by the straight line joining and , so the area under is approximated by a trapezoid of area . Summing over all panels and noticing every interior ordinate is shared by two adjacent trapezoids gives the composite formula:
where: is the panel width, and are the endpoint values (weight ), and every interior ordinate carries weight because it belongs to two panels. This formula works for any — there is no parity restriction.
Simpson's rule. Take the nodes three at a time and fit a parabola through each triple ; integrating that parabola exactly over the pair of panels it spans gives a much better local fit than a straight line for smooth . Because nodes are consumed two panels at a time, this requires to be even:
where: odd-indexed ordinates () are the midpoints of each parabolic panel and carry weight ; even-indexed interior ordinates () are shared endpoints between adjacent panels and carry weight ; the first and last ordinates always carry weight . A useful qualitative fact, not proved here but worth knowing for MA10002: Simpson's rule is exact even for cubic polynomials, not just quadratics, because the symmetric weighting makes the leading cubic error term cancel over a symmetric panel. This is why Simpson's rule generally converges faster than the trapezoidal rule as shrinks — it captures curvature that a straight-line fit simply cannot see. The trapezoidal rule, by contrast, is exact only for linear functions, but it has no restriction on and remains the fallback whenever the data gives an odd number of intervals.
The goal is to obtain the single-panel trapezoidal area from first principles by fitting a straight-line (degree-1) interpolant through two adjacent tabulated points and integrating that line exactly, then to show why summing single panels over collapses interior ordinates to weight in the composite formula.
Step 1. On with spacing , the straight line through and is the linear interpolant . This is exactly the line a ruler would draw between the two tabulated points — no information beyond those two values is used.
Step 2. Integrate over the panel: . Substituting the upper limit gives .
Step 3. Simplify: — the familiar trapezoid area, base and average height .
Step 4. Sum over all panels, to : . Every interior ordinate appears in exactly two adjacent brackets, so it is counted twice, while and each appear once. Collecting terms gives exactly , confirming the composite formula used above.
Worked example
Estimate by both rules using subintervals (), and compare against the exact value .
Step 1. Tabulate at : , , , , , , .
Step 2. Apply the trapezoidal rule. The interior sum is , so
Trapezoidal estimate: , an error of about against the exact .
Step 3. Apply Simpson's rule on the same table ( is even, as required). Odd-indexed ordinates sum to ; even-interior ordinates sum to .
Step 4. Compare. Simpson's estimate matches the exact to four decimal places, an error smaller than — roughly ten times more accurate than the trapezoidal estimate on identical data and identical . This is the expected pattern: for a smooth integrand, Simpson's parabolic fit tracks curvature that the trapezoidal straight-line fit misses, so it wins decisively even at a coarse . Trapezoidal ; Simpson's ; exact .
Common traps
- Applying Simpson's rule with an odd number of subintervals — the formula strictly requires even; with odd , fall back to the trapezoidal rule (or treat one leftover panel separately, which is outside this course's scope).
- Getting the weight pattern wrong — it is for Simpson's rule and for the trapezoidal rule; the first and last weights are always , and mixing up which interior ordinates get versus is the single most common exam slip.
- Mis-copying the scaling factor — for the trapezoidal rule versus for Simpson's rule; under exam pressure these are easy to swap, so always sanity-check the factor against the formula before submitting a numeric answer.
- Assuming a finer is always available — for tabulated data is fixed by the given table, and refining it is not an option; the skill being tested is choosing and correctly applying the rule that fits the given , not adaptive step control (outside this course).
Ask the tutor: If the Simpson's-rule weight pattern keeps tripping you up, ask the AI tutor for a mnemonic or to check your working on a fresh integral.
Why does Simpson's rule need an even number of subintervals but the trapezoidal rule does not?
Simpson's rule builds each parabolic panel from three consecutive nodes spanning two subintervals, so the subintervals must pair up exactly — hence even. The trapezoidal rule only ever needs two adjacent nodes per panel, so any single subinterval can be handled on its own and can be anything from upward. If your data table has an odd number of intervals, you cannot apply Simpson's rule directly to the whole range; the standard fix taught at this level is simply to use the trapezoidal rule instead.
If Simpson's rule is more accurate, why learn the trapezoidal rule at all?
Because it is simpler, has no parity restriction, and is often the only option when the data hands you an odd number of intervals. It is also the natural first step conceptually — Simpson's rule itself is best understood as an upgrade that replaces straight-line panels with parabolic ones. In this course you are expected to recognize which rule the given data supports and apply it correctly, not to always prefer one over the other regardless of the data.
How much accuracy do I actually gain by switching from trapezoidal to Simpson's on the same table?
In the worked example above, using the identical six-point table, the trapezoidal error was about while Simpson's error was under — roughly a tenfold improvement with no extra function evaluations. That gain comes purely from fitting a parabola instead of a line through the same data; it costs nothing extra to compute once you have the table, which is why Simpson's rule is preferred whenever is even and the integrand is reasonably smooth.