In calculus, the trapezoidal rule (also known as the trapezoid rule or trapezium rule) is a technique for numerical integration, i.e., approximating the definite integral: ∫ a b f ( x ) d x . {\displaystyle \int _{a}^{b}f(x)\,dx.}
The trapezoidal rule works by approximating the region under the graph of the function f ( x ) {\displaystyle f(x)} as a trapezoid and calculating its area. It follows that ∫ a b f ( x ) d x ≈ ( b − a ) ⋅ 1 2 ( f ( a ) + f ( b ) ) . {\displaystyle \int _{a}^{b}f(x)\,dx\approx (b-a)\cdot {\tfrac {1}{2}}(f(a)+f(b)).}
The trapezoidal rule may be viewed as the result obtained by averaging the left and right Riemann sums, and is sometimes defined this way. The integral can be even better approximated by partitioning the integration interval, applying the trapezoidal rule to each subinterval, and summing the results. In practice, this "chained" (or "composite") trapezoidal rule is usually what is meant by "integrating with the trapezoidal rule". Let { x k } {\displaystyle \{x_{k}\}} be a partition of [ a , b ] {\displaystyle [a,b]} such that a = x 0 < x 1 < ⋯ < x N − 1 < x N = b {\displaystyle a=x_{0}<x_{1}<\cdots <x_{N-1}<x_{N}=b} and Δ x k {\displaystyle \Delta x_{k}} be the length of the k {\displaystyle k} -th subinterval (that is, Δ x k = x k − x k − 1 {\displaystyle \Delta x_{k}=x_{k}-x_{k-1}} ), then ∫ a b f ( x ) d x ≈ ∑ k = 1 N f ( x k − 1 ) + f ( x k ) 2 Δ x k . {\displaystyle \int _{a}^{b}f(x)\,dx\approx \sum _{k=1}^{N}{\frac {f(x_{k-1})+f(x_{k})}{2}}\Delta x_{k}.} When the partition has a regular spacing, as is often the case, that is, when all the Δ x k {\displaystyle \Delta x_{k}} have the same value Δ x , {\displaystyle \Delta x,} the formula can be simplified for calculation efficiency by factoring Δ x {\displaystyle \Delta x} out:. ∫ a b f ( x ) d x ≈ Δ x 2 ( f ( x 0 ) + 2 f ( x 1 ) + 2 f ( x 2 ) + 2 f ( x 3 ) + 2 f ( x 4 ) + ⋯ + 2 f ( x N − 1 ) + f ( x N ) ) . {\displaystyle \int _{a}^{b}f(x)\,dx\approx {\frac {\Delta x}{2}}\left(f(x_{0})+2f(x_{1})+2f(x_{2})+2f(x_{3})+2f(x_{4})+\cdots +2f(x_{N-1})+f(x_{N})\right).}
The approximation becomes more accurate as the resolution of the partition increases (that is, for larger N {\displaystyle N} , all Δ x k {\displaystyle \Delta x_{k}} decrease).
As discussed below, it is also possible to place error bounds on the accuracy of the value of a definite integral estimated using a trapezoidal rule.