Solved.tools: Free Online Calculators & Tools

We use cookies for analytics and advertising. Learn more about our cookie policy

Trapezoidal Rule Calculator

Last updated: 7 August 2026

Reviewed by Gavin Meiring, Lead research and primary author ยท Doctoral Candidate (Corporate Governance) ยท Research and drafting assisted by AI

T = (h/2)[f(xโ‚€) + 2f(xโ‚) + 2f(xโ‚‚) + โ‹ฏ + 2f(xโ‚™โ‚‹โ‚) + f(xโ‚™)]
Was this helpful?


Trapezoidal Rule Calculator

The trapezoidal rule calculator approximates the definite integral of a function by dividing the area under the curve into trapezoids and summing their areas. It provides a more accurate estimate than basic Riemann sums and is used by calculus students, scientists processing experimental data, and engineers performing numerical integration. Enter your function, interval, and number of subintervals to get an instant approximation.

How to Use the Trapezoidal Rule Calculator

  1. Enter your function f(x) in the Trapezoidal Rule Calculator input field. Set the lower bound a and upper bound b of the integration interval.
  2. Choose the number of subintervals n. More subintervals improve accuracy.
  3. Click Calculate to apply the trapezoidal rule and display the result.
  4. Review the table of function values at each node and the area contributed by each trapezoid.

The Formula

For n subintervals of equal width delta_x = (b - a) / n, the trapezoidal rule gives:

T = (delta_x / 2) * [f(x_0) + 2f(x_1) + 2f(x_2) + ... + 2*f(x_{n-1}) + f(x_n)]

The first and last function values are used once; all interior values are used twice (because they form the shared edge between two adjacent trapezoids). The factor of 1/2 from the trapezoid area formula (half the sum of the parallel sides times the width) is already incorporated.

The error in the trapezoidal rule is proportional to (b-a)^3 * f''(max) / (12n^2), meaning accuracy improves rapidly as n increases.

Real-World Example

Approximate the integral of f(x) = e^x from x = 0 to x = 1 using 4 subintervals.

  1. delta_x = (1 - 0) / 4 = 0.25
  2. Node values: x_0 = 0, x_1 = 0.25, x_2 = 0.5, x_3 = 0.75, x_4 = 1.0
  3. Function values: f(0) = 1, f(0.25) = 1.2840, f(0.5) = 1.6487, f(0.75) = 2.1170, f(1) = 2.7183
  4. Apply the formula: T = (0.25/2) * [1 + 2(1.2840) + 2(1.6487) + 2(2.1170) + 2.7183]
  5. T = 0.125 * [1 + 2.568 + 3.2974 + 4.234 + 2.7183] = 0.125 * 13.8177 = 1.7272

The true value is e - 1 = 1.7183. With just 4 subintervals, the trapezoidal rule gives an answer accurate to within 0.5%.

Trapezoidal Rule Versus Simpson's Rule

The trapezoidal rule uses straight-line segments to approximate the curve within each subinterval, introducing error wherever the curve is not linear. Simpson's rule improves on this by fitting a parabola through each pair of subintervals, capturing curvature and reducing the error. For smooth functions, Simpson's rule is significantly more accurate for the same number of subintervals. However, the trapezoidal rule has an important advantage: it works directly with a table of data points without needing to know the function's formula, making it the standard method for integrating experimental data.

Convergence as the Interval Count Rises

Subintervals (n)Trapezoid valueError against e - 1 = 1.718282Error divided by the row above
11.8591410.140859-
21.7539310.0356493.95
41.7272220.0089403.99
81.7205190.0022374.00
161.7188410.0005594.00

f(x) = e^x on the interval from 0 to 1, where the exact integral is e - 1. The error falls by a factor of four each time the interval count doubles, which is the signature of a second-order method.

Four subintervals give a value right to two decimals, eight give three, and sixteen give four. When a table like this is available, the cheap check on any single answer is to double n and see how far the value moves. A shift in the fourth decimal at n = 16 is the method telling you it has settled.

How the Rule Is Built

The rule joins consecutive node values with straight lines and sums the areas of the resulting trapezoids. Endpoints are counted once and each interior node twice, because an interior node is the shared edge of two trapezoids. The error term is proportional to (b - a)^3 times the largest second derivative in the interval, divided by 12 n^2. For e^x between 0 and 1 the second derivative is e^x, so the worst case at n = 4 is e divided by 192, which is 0.01416. The table shows 0.008940, inside that bound.

Two differences from Simpson's rule are worth knowing when you choose between the two. The trapezoidal rule accepts any number of subintervals, odd counts included, and it is exact for any straight line because the second derivative is then zero. It converges more slowly: on this integral Simpson's rule at n = 4 returns 1.718319, an error of 0.000037, against the trapezoidal rule's 0.008940 at the same count. Where the function is smooth, Simpson's rule is the better use of the same nodes.

Frequently Asked Questions

Why is the trapezoidal rule more accurate than a Riemann sum? Riemann sums use rectangles, which approximate the curve with horizontal tops. The trapezoidal rule uses straight-line tops that follow the curve's trend within each subinterval, reducing the gap between the approximation and the true curve.

Is the trapezoidal rule exact for linear functions? Yes. If f(x) is a straight line, each trapezoid captures the exact area beneath it, giving a perfect result regardless of the number of subintervals used.

How do I estimate the error in my trapezoidal approximation? The error bound is |E_T| <= (b - a)^3 * M / (12n^2), where M is the maximum absolute value of f''(x) on [a, b]. Doubling n reduces the error by a factor of four, since it appears as n^2 in the denominator.

When should I use the trapezoidal rule instead of an exact integral? Use it when the integral has no closed-form antiderivative, when working from tabulated data rather than a formula, or when a quick numerical estimate is sufficient for the task at hand.

Worked example with a reciprocal function

The rule is easier to check on a function whose integral is a known constant. Take f(x) = 1/x on the interval from 1 to 2. The exact value is ln 2, which is 0.6931472 to seven decimal places.

At n = 4 the nodes are 1, 1.25, 1.5, 1.75 and 2, and the function values are 1.0000000, 0.8000000, 0.6666667, 0.5714286 and 0.5000000. The weighted sum is 1 + 2(0.8 + 0.6666667 + 0.5714286) + 0.5 = 5.5761905. The width is (2 - 1) / 4 = 0.25, so the approximation is 0.125 x 5.5761905 = 0.6970238.

Subintervals (n)Trapezoid valueAbsolute errorError divided by the row above
10.75000000.0568528-
20.70833330.01518623.74
40.69702380.00387663.92
80.69412190.00097473.98
160.69339120.00024403.99

The ratios settle towards four. Each doubling of n cuts the error by roughly the same factor, which is what a second-order method looks like in a table. On this integral, four subintervals are right to two decimals, eight are right to three, and sixteen are right to four.

The error bound in practice

The standard bound for the composite rule is |E| <= (b - a)^3 M / (12 n^2), where M is the largest absolute value of the second derivative on the interval. For f(x) = 1/x the second derivative is 2 / x^3, which is largest at x = 1, so M = 2 over [1, 2].

Subintervals (n)Bound (b - a)^3 M / (12 n^2)Observed error
20.04166670.0151862
40.01041670.0038766
80.00260420.0009747

The observed error sits well inside the bound at every count. That gap is normal. The bound uses the worst curvature anywhere in the interval, while the error depends on the average curvature, so the two come closest together only in the worst case.

What the composite rule assumes

Four conditions have to hold before the printed value means what its label says.

  • The nodes must be equally spaced. A single width applies only to a uniform grid. Data at irregular spacing needs the sum of the individual trapezoids, which stays exact for straight-line data but no longer carries the same error formula.
  • The function must be continuous on the interval, with a continuous second derivative for the error term to mean anything. A jump or a pole inside the interval puts the answer at the mercy of where the grid happens to fall.
  • The subinterval count must be a whole number of at least one, and the calculator's field stops at 500.
  • The approximation approaches a convex curve from above and a concave curve from below, so the sign of the error tells you which way the curve bends.

A note on the reference value

The calculator prints an "Exact value (reference)" line under the result. That figure comes from a composite Simpson's rule evaluation at 10,000 intervals rather than from symbolic integration, so it is a much better estimate and not a proof. The tool also displays at most the first eight trapezoids.

For a check that does not depend on any numerical scheme, compare the displayed value against a constant you know. On f(x) = 1/x over [1, 2] the printed reference should match ln 2 = 0.6931472. The error analysis behind the |E| <= (b - a)^3 M / (12 n^2) bound comes from the Euler-Maclaurin summation formula, set out in Kendall E. Atkinson, An Introduction to Numerical Analysis, second edition (1989).


Also try these free tools: