There are a number of methods for approximating the integral of a function \(f\) over a closed interval \([a,b]\), when the actual integral cannot be calculated. Riemann sums are one method of integral approximation. The general idea is to partition the interval into \(n\) smaller pieces. For each subinterval \([x_i, x_{i+1}]\), a representative point \(x^*\) is chosen. Adding the area of the rectangles with width \(x_{i+1} - x_i\) and height \(f(x^*)\) yields an approximation of the integral:
\[ \int_a^b f(x)dx \approx \sum_{i=0}^{n-1} f(x^*)(x_{i+1} - x_i) \]
While the width of the subintervals is not required to be equal, many common formulations of the Riemann sum use a constant width. The representative point chosen from each subinterval can, in general, be any point in that subinterval. However, the Riemann sums considered in this app are defined by the points chosen:
- the left endpoint rule has \(x^* = x_i\) for each subinterval \([x_i, x_{i+1}]\).
- the ridght endpoint rule has \(x^* = x_{i+1}\) for each subinterval \([x_i, x_{i+1}]\).
- the midpoint rule has \(x^* = \frac{x_{i+1} - x_i}{2}\) for each subinterval \([x_i, x_{i+1}]\).
The trapezoidal rule is differs from the above methods in that instead of adding rectangular areas on each subinterval \([x_i, x_{i+1}]\), we sum the area of a trapezoid with vertices \([x_i, 0], [x_{i+1}, 0], [x_i, f(x_i)], [x_{i+1}, f(x_{i+1})]\).The value of the approximation given by the trapezoidal rule is the average of the approximations given by the left and right endpoint rules.
Simpson's rule requires an even number of subintervals, which are paired together. A quadratic interpolating polynomial through the points on the curve at left endpoint, right endpoint, and center of each pairing of subintervals is used instead of a straight line at the top of the subdivisions. As a result, Simpson's rule gives the exact value of the integral for any quadratic polynomial.
The accuracy of each approximation is improved as the number of subintervals is increased.