Trapezoidal rule is a technique used to approximate the value of a definite integral ($\int_{a}^{b}$ f(x)dx). Supposing f(x) is continuous on [a, b] divide [a, b] into n sub intervals of equal length $\bigtriangleup$x = $\frac{b - a}{n}$.  Using n + 1 points we get $x_{0}$ = a, $x_{1}$ = a + $\bigtriangleup$x, $x_{2}$ = a + 2$\bigtriangleup$x, ......, $x_{n}$ = a + n$\bigtriangleup$x = b.

f(x) at these points is $y_{0}$ = f($x_{0}$), $y_{1}$ = f($x_{1}$),.......,$y_{n}$ = f($x_{n}$). As straight lines are formed between the points (x$_{i-1}$, y$_{i-1}$) and (x$_{i}$, y$_{i}$) for 1 $\leq$ i $\leq$ n approximate the integral using n trapezoids.
Trapezoidal Rule

Adding the area of a rectangle and a triangle the area of trapezoid is
 
A = $y_{0}$$\bigtriangleup$x + $\frac{1}{2}$ ($y_{1} - y_{0}$) $\bigtriangleup$x

A = $\frac{(y_{0} + y_{1})\bigtriangleup x}{2}$

Area of trapezoid is A = $\frac{(y_{0} + y_{1})\bigtriangleup x}{2}$
Adding the area of n trapezoids the approximation is

$\int_{a}^{b}f(x)dx$  $\approx$  $\frac{(y_{0}+y_{1})\bigtriangleup x}{2}$ + $\frac{(y_{1}+y_{2})\bigtriangleup x}{2}$ + ........ + $\frac{(y_{n-1} + y_{n})\bigtriangleup x}{2}$

which is simplified to

$\int_{a}^{b}f(x)dx$  $\approx$ $\frac{\bigtriangleup x}{2}$ ($y_{0}  + 2y_{1}+ 2y_{2}+ ...... + 2y_{n-1}+y_{n})$
Therefore the formula for trapezoidal rule is
$\int_{a}^{b}f(x)dx$  $\approx$ $\frac{\bigtriangleup x}{2}$ ($y_{0}  + 2y_{1}+ 2y_{2}+ ...... + 2y_{n-1}+y_{n})$