---
tag: 7R0F4956PX
kind: definition
name: Trapezoidal rule
msc: [65D32, 41A55, 65D30]
defines: FH0538XCZR
uses: [ADSVMCY77A, BQPQAY1FDJ, ZYT1JNT1Y0]
sources:
  - url: https://en.wikipedia.org/wiki/Trapezoidal_rule
---

## Definition

Let $a < b$ and let $f \colon [a, b] \to \R$ be continuous.
The *trapezoidal rule* is the [[quadrature rule|ADSVMCY77A]]
$$T(f) = \frac{b - a}{2} \big( f(a) + f(b) \big).$$
For an integer $N \ge 1$, let $h = (b - a)/N$ and $x_i = a + i h$ for $i = 0, \dots, N$.
The *composite trapezoidal rule* with $N$ subintervals is
$$T_N(f) = h \left( \frac{f(x_0)}{2} + f(x_1) + \cdots + f(x_{N-1}) + \frac{f(x_N)}{2} \right),$$
the sum of $T$ over the subintervals $[x_{i-1}, x_i]$.

## Remarks

$T$ is the closed [[Newton–Cotes formula|BQPQAY1FDJ]] with $n = 1$, and its [[degree of exactness|ZYT1JNT1Y0]] is $1$.
Example: for $f(x) = x^2$ on $[0, 1]$ and $N = 2$, $T_2(f) = \tfrac{1}{2}\big(0 + \tfrac{1}{4} + \tfrac{1}{2}\big) = \tfrac{3}{8}$, while $\int_0^1 x^2\, dx = \tfrac{1}{3}$.
Non-example: the left Riemann sum $h \big( f(x_0) + \cdots + f(x_{N-1}) \big)$ is not the composite trapezoidal rule.
It gives full weight to $f(x_0)$ and none to $f(x_N)$; for $f(x) = x$ on $[0, 1]$ and $N = 1$ it gives $0$ instead of $1/2$.
The composite rule is the average of the left and right Riemann sums.
For a continuous function of period $b - a$, $T_N(f) = h \sum_{i=0}^{N-1} f(x_i)$, and for smooth periodic $f$ the error decreases faster than any power of $h$.
