Numerical Integration
Numerical integration gives you practical ways to approximate definite integrals when you can't find an antiderivative (or when one doesn't exist in closed form). These methods break the area under a curve into simpler geometric shapes, then sum those areas to estimate the integral. The key questions are always: how close is the approximation? and how can you make it more accurate?
Midpoint and Trapezoidal Rule Applications
The midpoint rule approximates the integral by building rectangles whose heights are determined by the function value at the midpoint of each subinterval. Because it samples the middle rather than the edges, it often performs surprisingly well.
where and is the midpoint of the th subinterval.
The trapezoidal rule connects function values at the endpoints of each subinterval with straight lines, forming trapezoids instead of rectangles. This captures some of the curve's slope that rectangles miss.
where .
Notice the pattern in the trapezoidal formula: the first and last function values get a coefficient of 1, while every interior point gets a coefficient of 2. This comes from each interior point being shared by two adjacent trapezoids.
Both methods are Riemann sum approximations. They partition into equal subintervals and sum the areas of simpler shapes to estimate the total.
Quick example: To approximate with , you'd use . For the midpoint rule, evaluate at . For the trapezoidal rule, evaluate at and apply the weighting pattern above.
Error Calculations in Numerical Integration
Once you have an approximation, you need to measure how good it is.
Absolute error is the straightforward difference between the exact value and your approximation:
For instance, the exact value of . If your trapezoidal approximation with gives 0.34375, then .
Relative error expresses that absolute error as a proportion of the true value, which is more useful for comparing accuracy across different problems:
In the example above, , or about 3.1%.

Error-Bound Formulas
You won't always know the exact value (that's the whole point of numerical integration). Error-bound formulas give you a guaranteed upper limit on the error without needing the exact answer.
- Midpoint rule error bound:
- Trapezoidal rule error bound:
In both formulas, is the maximum value of on .
A few things to notice here:
- The midpoint bound has 24 in the denominator while the trapezoidal bound has 12. This means the midpoint rule's error bound is actually half that of the trapezoidal rule for the same . The midpoint rule is often more accurate than it looks.
- Both errors shrink proportionally to . Doubling cuts the maximum error by a factor of 4.
- Finding requires you to compute , then find its maximum absolute value on . You can often use calculus techniques or just evaluate at the endpoints and any critical points.
Over- vs. Underestimation
The concavity of determines whether each method overshoots or undershoots the true value. This is worth memorizing because it comes up on exams constantly.
| Concavity | Midpoint Rule | Trapezoidal Rule |
|---|---|---|
| Concave up () | Overestimates | Underestimates |
| Concave down () | Underestimates | Overestimates |
Why this happens: When a curve is concave up, it bends upward like a bowl. The midpoint of each subinterval sits above the chord connecting the endpoints, so midpoint rectangles are too tall. Trapezoids, on the other hand, connect the endpoints with straight lines that sit below the curve, so they miss area.
The pattern flips for concave down. If the function changes concavity on the interval, the over- and underestimation effects partially cancel, and you can't make a clean prediction about which direction the error goes.

Simpson's Rule for Definite Integrals
Simpson's rule takes accuracy a step further by fitting parabolas (not lines or flat tops) through consecutive groups of three points. Because parabolas can match curvature, this method is significantly more precise.
where and must be even.
The coefficient pattern is: 1, 4, 2, 4, 2, ..., 4, 2, 4, 1. The alternating 4s and 2s come from how adjacent parabolic segments share points.
Simpson's rule error bound:
where is the maximum value of on . Note that this uses the fourth derivative, not the second.
The error decreases as , which is dramatically faster than the rate of the midpoint and trapezoidal rules. Doubling cuts the error by a factor of 16.
A remarkable consequence: Simpson's rule gives exact results for any polynomial of degree 3 or less, because the fourth derivative of such polynomials is zero, making .
Finding for a specified accuracy:
- Compute and find its maximum absolute value on .
- Set the error bound less than your desired tolerance: .
- Solve for : .
- Round up to the next even integer (since Simpson's rule requires even ).
Advanced Numerical Integration Techniques
- Composite rules are what you've already been using: applying the midpoint, trapezoidal, or Simpson's rule across many subintervals and summing the results. The formulas above are all composite versions of their respective rules.
- Gaussian quadrature methods choose evaluation points and weights strategically (not equally spaced) to achieve higher accuracy with fewer function evaluations. These are common in engineering and scientific computing.
- Adaptive quadrature algorithms automatically use more subintervals where the function changes rapidly and fewer where it's smooth, optimizing the tradeoff between accuracy and computation.