Trapezoidal Rule Calculator
Approximate a definite integral with the trapezoidal rule from the function values at n + 1 equally spaced points between a and b, or from the average trapezoid height.
Last updated: September 2026
Approximate Integral
22
Formula below · 2 sources (tutorial.math.lamar.edu, mathworld.wolfram.com) · Updated Sep 2026
Compare with similar
About this calculator
The trapezoidal rule approximates ∫ₐᵇ f(x) dx by splitting [a, b] into n equal subintervals of width h = (b − a) ÷ n and replacing the curve on each by a straight line:
T = (h ÷ 2) × [f(x₀) + 2f(x₁) + 2f(x₂) + … + 2f(xₙ₋₁) + f(xₙ)].
Enter the function values at the n + 1 points a, a + h, …, b, separated by commas; the number of values sets n. The values can come from a formula you evaluate or from measured data at equal spacing. If you leave the list empty, the calculator uses the shortcut T = (b − a) × average trapezoid height, where the average height is the mean of the n values (f(xᵢ₋₁) + f(xᵢ)) ÷ 2.
The error is −(b − a) h² f″(ξ) ÷ 12 for some ξ in [a, b], so halving h cuts the error by about four. The rule overestimates the integral where f is convex (curving up, like x²) and underestimates it where f is concave. Simpson's rule, which fits parabolas, is usually far more accurate for smooth functions with the same points. The diagram below draws the trapezoids from the average height and the number of subintervals.
How to use
Example (the defaults): f(x) = x² on [0, 4] with n = 4, so h = 1 and the values are 0, 1, 4, 9, 16. T = (1 ÷ 2) × [0 + 2(1 + 4 + 9) + 16] = 0.5 × 44 = 22. The exact integral is 64 ÷ 3 = 21.33, so the error is 0.67, as the formula predicts (4 × 1² × 2 ÷ 12 = 0.67). With n = 8 (values at 0, 0.5, …, 4) T = 21.5. Shortcut: on [1, 3] with an average trapezoid height of 2.75, clear the f(x) list and T = 2 × 2.75 = 5.5.
Frequently asked questions
How accurate is the trapezoidal rule compared to other numerical integration methods?
The trapezoidal rule has an error of order O(h²), meaning halving the step size reduces the error by roughly a factor of four. Simpson's rule, by comparison, achieves O(h⁴) accuracy with the same number of evaluations, making it more efficient for smooth functions. However, the trapezoidal rule is simpler to implement and performs surprisingly well on periodic or very smooth functions, sometimes matching higher-order methods in practice.
When should I use the trapezoidal rule instead of finding an exact integral?
Use the trapezoidal rule when the function has no closed-form antiderivative, when you only have discrete data points rather than a formula, or when a quick numerical estimate is sufficient. Common applications include engineering load calculations, probability distributions without analytic CDFs, and experimental data analysis. For highly oscillatory or discontinuous functions, consider increasing n or switching to adaptive integration methods.
How does increasing the number of subintervals improve the trapezoidal approximation?
Each subinterval is approximated by a straight-line chord, and the error comes from the curvature the chord ignores. With more subintervals the step width h shrinks, so each chord deviates less from the true curve and the total error decreases quadratically with h. In practice, doubling n roughly quarters the error. You can verify convergence by comparing results for n and 2n; when they agree to your desired precision, you have a reliable estimate.
Can I use measured data instead of a formula?
Yes, as long as the points are equally spaced: enter the readings in order, and set a and b to the first and last x positions. For unequal spacing, add up (xᵢ − xᵢ₋₁) × (yᵢ₋₁ + yᵢ) ÷ 2 for each interval.
Related calculators
Sources & references
Think a result is wrong? Report a problem with this calculator.