Mercyhurst UniversityMath DeptDr Williams Home

Approximating the Definite Integral


Zoom:

f(x) =


Number of subintervals:

Interval: [ , ]

\(\int_a^b f(x) dx \) = 0

Midpoint Rule Approximation 0
Midpoint Rule Error 0
Left Endpoint Rule Approximation 0
Left Endpoint Rule Error 0
Right Endpoint Rule Approximation 0
Right Endpoint Rule Error 0
Trapezoidal Rule Approximation 0
Trapezoidal Rule Error 0
Simpson's Rule Approximation 0
Simpson's Rule Error 0

Integral Approximation

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 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.

Using the Applet

Enter a function, the number of subintervals, and the lower and upper bounds for the definite integral. The (truncated) value of the definite integral will be displayed, calculated using the Fundamental Theorem of Calculus (though this too is a computed approximation). Each of the approximations, along with their error, will also update. Check the box next to the approximation types to view regions represented by each term of the approximation.

Click and drag to move the graph, and adjust the view with the zoom range slider.

About this Applet

This applet was created using Math.js and HTML5 Canvas and was last updated January 2018.