# Trapezium formula

The special case of the Newton–Cotes quadrature formula in which two nodes are taken:

$$\tag{1 } \int\limits _ { a } ^ { b } f ( x) dx \cong \ { \frac{b - a }{2} } [ f ( a) + f ( b)].$$

If the integrand $f$ differs strongly from a linear function, then formula (1) is not very exact. In this case the interval $[ a, b]$ is divided into $n$ subintervals $[ x _ {i} , x _ {i + 1 } ]$, $i = 0 \dots n - 1$, of length $h = ( b- a)/n$, and for the calculation of the integral over $[ x _ {i} , x _ {i + 1 } ]$ one uses the trapezium formula

$$\int\limits _ {x _ {i} } ^ { {x _ {i} + 1 } } f ( x) dx \cong \ { \frac{h}{2} } [ f ( x _ {i} ) + f ( x _ {i + 1 } )].$$

Summation of the left- and right-hand sides of this approximate equality with respect to $i$ from 0 to $n - 1$ leads to the composite trapezium formula:

$$\tag{2 } \int\limits _ { a } ^ { b } f ( x) dx \cong \ h \left [ { \frac{f ( a) }{2} } + f ( x _ {1} ) + \dots + f ( x _ {n - 1 } ) + { \frac{f ( b) }{2} } \right ] ,$$

where $x _ {j} = a + jh$, $j = 0 \dots n$. The quadrature formula (2) is also called the trapezium formula (without adding the word composite). The algebraic degree of accuracy of the quadrature formula (2), as well as of (1), is equal to 1. The quadrature formula (2) is exact for the trigonometric functions

$$\cos \frac{2 \pi }{b - a } kx,\ \ \sin \frac{2 \pi }{b - a } kx,\ \ k = 0 \dots n - 1.$$

In the case when $b - a = 2 \pi$, formula (2) is exact for all trigonometric polynomials of order not exceeding $n - 1$; furthermore, its trigonometric degree of accuracy is equal to $n - 1$.

If the integrand $f$ is twice-continuously differentiable on $[ a, b]$, then the error $R ( f )$ of the quadrature formula (2), that is, the difference between the integral and the quadrature sum, is given by

$$R ( f ) = \ - { \frac{b - a }{12} } h ^ {2} f ^ { \prime\prime } ( \xi ),$$

where $\xi$ is a point of $[ a, b]$.

$$\int\limits _ { a } ^ { b } f( x) dx =$$
$$= \ h \left [ \frac{f(a)}{2} + f( x _ {1} ) + \dots + f( x _ {n-} 1 ) + \frac{f(b)}{2} \right ] - \frac{b-a}{12} h ^ {2} f ^ { \prime\prime } ( \xi )$$