The trapezoidal rule is a numerical method for approximating the definite integral of a function. It is particularly useful when the function is not easily integrable analytically. The trapezoidal rule approximates the area under a curve by dividing it into trapezoids rather than rectangles.
Definition of the Integral: We want to approximate the definite integral of a function \( f(x) \) over the interval \([a, b]\):
\[
I = \int_a^b f(x) \, dx
\]
Divide the Interval: Divide the interval \([a, b]\) into \( n \) equal subintervals of width \( h \):
\[
h = \frac{b - a}{n}
\]
The points dividing the intervals are:
\[
x_0 = a, x_1 = a + h, x_2 = a + 2h, \ldots, x_n = b
\]
Trapezoidal Approximation: The area under the curve on each subinterval \([x_i, x_{i+1}]\) can be approximated by the area of the trapezoid formed by the line segments joining the points \((x_i, f(x_i))\) and \((x_{i+1}, f(x_{i+1}))\).
The area \( A_i \) of each trapezoid is given by:
\[
A_i = \frac{1}{2} \left( f(x_i) + f(x_{i+1}) \right) h
\]
Sum the Areas: The total area \( I \) can be approximated by summing the areas of all trapezoids:
\[
I \approx \sum_{i=0}^{n-1} A_i = \sum_{i=0}^{n-1} \frac{1}{2} \left( f(x_i) + f(x_{i+1}) \right) h
\]
Simplify the Summation: Factor out \( \frac{h}{2} \):
\[
I \approx \frac{h}{2} \left( f(x_0) + 2 \sum_{i=1}^{n-1} f(x_i) + f(x_n) \right)
\]
This leads to the final form of the trapezoidal rule:
\[
I \approx \frac{b - a}{2n} \left( f(a) + 2 \sum_{i=1}^{n-1} f(a + ih) + f(b) \right)
\]