The idea of the following lemma, known as the trapezoid rule is illustrated in the following figure.
For a given, "sufficiently smooth" function $f:[a,b]\to\mathbb R$ we want to calculate the area under the curve of this function, which equals the integral $\int_{a}^b f(x)dx.$ If for whatever reasons, the exact calculation of the integral is too complicated, we can approximate this area by calculating the area of the trapezoid in the points $a$, $b$, $f(b)$ and $f(a)$ instead, which is easily found using the formula $$(b-a)\frac{f(a)+f(b)}{2}.$$
When doing so, we will make an error $R.$ We can expect that this error gets smaller and smaller if we replace the original trapezoid by the sum of areas of $n\ge 2$ smaller trapezoids with equal bases built as follows: * We choose the number of trapezoids $n\ge 2.$ * We choose the length of the basis of all trapezoids to be $h:=\frac{b-a}n,$ such that we have $n+1$ points $x_\nu:=a+\nu h.$ By this choice, we will have $x_0=a$ and $x_n=b.$ * Since the area of a single $\nu$-th smaller trapezoid (for $\nu=1,\ldots,n$) is given by $$h\frac{f(x_\nu)+f(x_{\nu-1})}{2},$$ the sum of all these $n$ trapezoids is given by $$h\left(\frac{f(a)}{2}+\sum_{\nu=1}^{n-1}f(x_\nu)+\frac{f(b)}{2}\right),$$ which is an approximation of the actual integral.
The following lemma specifies what exactly is meant by "sufficiently smooth" and how good we can expect this approximation to be.
Let the function $f:\mathbb R\to\mathbb R$ be a twice continuously differentiable. Let $n\ge 1$ be a natural number. For the closed real interval $[a,b]$, the Riemann integral $\int_a^b f(x)dx$ can be approximated using the function values of $f$ via $$\int_a^b f(x)dx=\left(\frac{f(a)}{2}+\sum_{\nu=1}^{n-1}f(a+\nu h)+\frac{f(b)}{2}\right)h+R,$$ where $h:=\frac{b-a}n$ and the absolute error term $|R|$ has an upper bound using the supremum of the second derivative of $f$ on the interval $[a,b]$ defined as follows:
$$|R|\le \frac{(b-a)h^2}{12}\cdot \sup\{|f^{\prime\prime}(x)|\mid\text{for all } x\in[a,b]\}.$$
Proofs: 1