Trapezoidal Rule Calculator

Trapezoidal estimate2.75
Exact integral2.67
Absolute error0.0833
Subinterval width h0.5000
How this was calculated
  1. Subinterval width h = (2.00 - 0.00) / 4 = 0.5000.
  2. Endpoint values: f(0.00) = 0.00 and f(2.00) = 4.00; the 3 interior values sum to 3.50.
  3. Trapezoidal estimate = h x ((f(start) + f(end)) / 2 + interior sum) = 0.5000 x ((0.00 + 4.00) / 2 + 3.50) = 2.75.
  4. The exact integral of the cubic is 2.67, so the absolute error is 0.0833.
  5. The trapezoidal rule's error shrinks roughly with 1/n²: doubling the subintervals quarters the error, but it never vanishes for a curved function.

This trapezoidal rule calculator approximates definite integrals using the trapezoidal rule, which slices an interval into n subintervals and replaces each slice of curve with a straight line, forming trapezoids. The underlying formula is integral ≈ h × ((f(a) + f(b)) / 2 + sum of interior values), where h = (b − a) / n. Built specifically for cubic polynomials of the form f(x) = a3x³ + a2x² + a1x + a0, the calculator returns both the trapezoidal estimate and the exact integral side by side, so you can immediately see how close the approximation lands. For instance, integrating x² on [0, 2] with n = 4 yields an estimate of 2.75 against the exact 2.67, an absolute error of 0.0833 that overestimates because x² curves upward. A straight line such as f(x) = x on [0, 4] with n = 4 gives exactly 8.00, since trapezoids tile a straight line perfectly.

The trapezoidal rule is the accepted standard for this kind of numerical integration because it balances simplicity with reliable accuracy: the error shrinks roughly with 1/n², so doubling the number of subintervals quarters the error, though for a curved function it never quite reaches zero. That predictable convergence is why the method remains a staple in calculus courses and engineering practice. This page shows the full formula, step-by-step workings for each input, worked examples such as (x − 1)² on [0, 3] with n = 6 giving 3.13 against the exact 3.00, and the sources behind the calculations.

Worked examples

x² on [0, 2], n = 4

Primary result: 2.75 — the trapezoids overshoot the exact 2.67 because x² curves upward. (0 · 1 · 0 · 0 · 0 · 2 · 4)

Trapezoidal estimate2.75
Exact integral2.67
Absolute error0.0833
Subinterval width h0.5000

x on [0, 4], n = 4

Primary result: 8.00 — exact for a straight line: trapezoids tile it perfectly. (0 · 0 · 1 · 0 · 0 · 4 · 4)

Trapezoidal estimate8.00
Exact integral8.00
Absolute error0.0000
Subinterval width h1.0000

(x - 1)² on [0, 3], n = 6

Primary result: 3.13 — six subintervals bring the error down to about 0.13. (0 · 1 · -2 · 1 · 0 · 3 · 6)

Trapezoidal estimate3.13
Exact integral3.00
Absolute error0.1250
Subinterval width h0.5000

The trapezoidal rule formula

The trapezoidal rule approximates a definite integral by slicing the interval into n subintervals and replacing each slice of curve with a straight line, forming trapezoids. The width of every subinterval is h = (b - a) / n, where a and b are the bounds of integration. Geometrically, you can picture a series of trapezoids sitting beneath the curve: the top edge of each trapezoid is the straight line that connects the function values at the left and right ends of that subinterval. Summing the areas of these trapezoids gives the estimate.

The compact form of the formula is integral ≈ h × ((f(a) + f(b)) / 2 + sum of interior values). The two endpoints, f(a) and f(b), are averaged together and count once each in that averaged term. Every interior point — the function values at x₁, x₂, and so on up to xₙ₋₁ — counts once each inside the summation. A trapezoidal rule calculator applies this structure directly: it computes h, evaluates the function at each node, and returns the summed estimate.

A quick worked example shows the formula in action. For f(x) = x² on [0, 2] with n = 4, the estimate is 2.75 against the exact value of 2.67, giving an absolute error of 0.0833. The estimate is an overestimate because x² curves upward, so the straight-line tops of the trapezoids sit above the curve. By contrast, the line f(x) = x on [0, 4] with n = 4 gives exactly 8.00, because trapezoids tile a straight line perfectly. A third example, f(x) = (x - 1)² on [0, 3] with n = 6, gives 3.13 against the exact 3.00.

The error shrinks roughly with 1/n²: doubling the number of subintervals quarters the error, but for a curved function the estimate never quite reaches zero. This calculator integrates cubic polynomials f(x) = a3x³ + a2x² + a1x + a0 and shows the exact integral beside the estimate, so you can see the gap between approximation and true value directly. Comparing the two outputs makes it easy to judge how many subintervals you need for a desired level of accuracy.

Worked examples

The clearest way to understand any trapezoidal rule calculator is to test it against functions whose exact integrals are known. Take f(x) = x² on the interval [0, 2] with n = 4. The step size is h = (2 − 0) / 4 = 0.5. The trapezoidal rule approximates a definite integral by slicing the interval into n subintervals and replacing each slice of curve with a straight line, forming trapezoids: integral ≈ h × ((f(a) + f(b)) / 2 + sum of interior values). Plugging in the values at x = 0, 0.5, 1, 1.5, and 2 gives an estimate of 2.75. The exact integral is 2.67, so the absolute error is 0.0833. Because x² curves upward, the straight-line trapezoids sit slightly above the curve, producing an overestimate.

Next consider the line f(x) = x on [0, 4] with n = 4. Here the step size is h = (4 − 0) / 4 = 1. The estimate comes out to exactly 8.00, which matches the exact integral of 8.00 with zero error. This is no coincidence: trapezoids tile a straight line perfectly, so a linear function produces no approximation error at all. The trapezoidal rule is exact whenever the function has no curvature.

A third verified case is f(x) = (x − 1)² on [0, 3] with n = 6. The step size is h = (3 − 0) / 6 = 0.5. The estimate is 3.13, while the exact integral is 3.00. Again the function curves upward, so the trapezoids overshoot the true area, this time by 0.13. Comparing this to the x² example shows the pattern: the error shrinks roughly with 1/n², so doubling the number of subintervals quarters the error. However, for a curved function the error never quite reaches zero — it only gets progressively smaller.

This calculator integrates cubic polynomials f(x) = a3x³ + a2x² + a1x + a0 and shows the exact integral beside the estimate, making it easy to confirm the pattern above. For straight lines the two numbers match, and for curves the estimate sits slightly high or low depending on the direction of curvature. The three cases below summarize the verified results.

FunctionIntervalnTrapezoidal estimateExact integralAbsolute error
x²[0, 2]42.752.670.0833
x[0, 4]48.008.000
(x − 1)²[0, 3]63.133.000.13

Where the error comes from

The trapezoidal rule approximates a definite integral by slicing the interval into n subintervals and replacing each slice of curve with a straight line, forming trapezoids. When the function is a straight line itself, those trapezoids match the area perfectly. The worked example for the line f(x) = x on [0, 4] with n = 4 gives exactly 8.00 — trapezoids tile a straight line perfectly, with zero error. Error appears only when the function curves away from the straight-line tops of the trapezoids.

The direction of the error depends on the shape of the curve. A convex curve, one that bends upward like x², lies below the straight line connecting two points on the curve. Because the trapezoid's top edge sits above the curve, the trapezoidal rule captures extra area and overestimates the true integral. The worked example for x² on [0, 2] with n = 4 gives 2.75 against the exact 2.67 — an absolute error of 0.0833, an overestimate because x² curves upward. A concave curve bends downward, so the trapezoid's top edge falls below the curve and the rule underestimates. The worked example for (x - 1)² on [0, 3] with n = 6 gives 3.13 against the exact 3.00, again an overestimate because the parabola opens upward on that interval.

The error shrinks roughly with 1/n²: doubling the number of subintervals quarters the error, but for a curved function it never quite reaches zero. This relationship gives you a practical way to choose n for a target accuracy. If a trapezoidal rule calculator reports an estimate with n = 4 and you suspect the error is too large, switching to n = 8 should shrink that error by a factor of four, and n = 16 by another factor of four. You can compare successive estimates until the difference between them falls below your tolerance, then treat the latest value as reliable.

This calculator integrates cubic polynomials f(x) = a3x³ + a2x² + a1x + a0 and shows the exact integral beside the estimate. Because the exact value is displayed, you can see the overestimate or underestimate directly and watch how increasing n drives the estimate toward the true integral, consistent with the 1/n² error behavior.

Doubling n quarters the error: if n = 4 gives an absolute error of 0.0833, then n = 8 should give roughly 0.0208, and n = 16 roughly 0.0052.

Trapezoidal rule vs Simpson's rule

The trapezoidal rule approximates a definite integral by slicing the interval into n subintervals and replacing each slice of curve with a straight line, forming trapezoids. The formula is integral ≈ h × ((f(a) + f(b)) / 2 + sum of interior values), with h = (b − a) / n. Simpson's rule takes a different approach: it fits parabolas through groups of three points instead of using straight lines. This makes Simpson's exact for cubic polynomials, meaning it can integrate f(x) = a3x³ + a2x² + a1x + a0 without any error at all. The trapezoidal rule, by contrast, does not share that property.

Where the trapezoidal rule wins is simplicity and flexibility. It works for any positive integer n — odd, even, large, or small — while Simpson's rule requires an even number of subintervals. That requirement comes from the fact that each parabola spans two subintervals, so the total count must be divisible by 2. The trapezoidal rule also handles tabulated data with no extra effort. If you have a table of x and f(x) values sampled at uneven intervals from a sensor or an experiment, you can apply the trapezoidal formula directly to each pair of adjacent points. Simpson's rule cannot adapt as easily to unevenly spaced or arbitrarily tabulated data.

The accuracy difference shows up clearly in worked examples. For f(x) = x² on [0, 2] with n = 4, the trapezoidal rule gives 2.75 against the exact value of 2.67, an absolute error of 0.0833. The estimate is an overestimate because x² curves upward, and each straight-line slice sits slightly above the true curve. For the straight line f(x) = x on [0, 4] with n = 4, the trapezoidal rule gives exactly 8.00 — trapezoids tile a straight line perfectly, so there is no error at all. For a more curved case, (x − 1)² on [0, 3] with n = 6 gives 3.13 against the exact 3.00, again an overestimate.

The error in the trapezoidal rule shrinks roughly with 1/n²: doubling the number of subintervals quarters the error. However, for a curved function the error never quite reaches zero, no matter how many subintervals you use. This is the key trade-off versus Simpson's rule. A trapezoidal rule calculator is the right tool when you need a method that works for any n, handles tabulated data, and is easy to verify by hand. Simpson's rule is the better choice when your function is a cubic or close to it and you need maximum accuracy with fewer subintervals.

  • Trapezoidal rule: straight-line slices, works for any n, handles tabulated data
  • Simpson's rule: parabolic slices, requires even n, exact for cubic polynomials
  • Error in trapezoidal rule shrinks roughly with 1/n² — doubling n quarters the error
This calculator integrates cubic polynomials f(x) = a3x³ + a2x² + a1x + a0 and shows the exact integral beside the estimate, so you can see the trapezoidal rule's error directly.

FAQs

What is the trapezoidal rule?

The trapezoidal rule is a numerical integration method that approximates the area under a curve using trapezoids. The formula is h multiplied by the quantity ((f(a) + f(b)) / 2 + interior sum). It divides the region into vertical slices shaped like trapezoids, then sums their areas to estimate the total integral across the chosen interval.

How accurate is the trapezoidal rule for x² on [0, 2] with n = 4?

For f(x) = x² on the interval [0, 2] with n = 4, the trapezoidal rule gives an approximation of 2.75. The exact integral is 2.67, so the error is 0.0833, which means the result is about 3.12% high. This shows the method slightly overestimates for upward-curving functions like this quadratic.

When is the trapezoidal rule exact?

The trapezoidal rule is exact for straight-line functions. For example, f(x) = x on the interval [0, 4] gives exactly 8.00 at any n, because trapezoids match a line perfectly. Since the top edge of each trapezoid lies directly on the line, the approximation equals the true area with no error at all.

How do I reduce the error?

Use more subintervals to reduce the error. The error falls roughly with 1/n², so doubling n quarters it. This means increasing the number of subintervals produces a significantly more accurate result, because the trapezoids become narrower and better conform to the shape of the curve being integrated across the interval.

Does the trapezoidal rule overestimate or underestimate?

It can do both, depending on curvature. The trapezoidal rule overestimates where the curve bends upward, which is convex, and underestimates where it bends downward. The direction of the error depends on whether the function curves above or below the straight trapezoid edges connecting the evaluated points along the interval.

What functions can this calculator integrate?

This calculator integrates cubic polynomials of the form f(x) = a3x³ + a2x² + a1x + a0 over any interval. It displays the exact integral alongside the trapezoidal approximation for comparison, so you can see how close the estimate is to the true value for the cubic polynomial you enter.

Sources

Related calculators

Simpson's Rule Calculator
Simpson's 1/3 rule for the integral of a cubic polynomial — exact for cubics, with the exact integral and error shown for comparison.
Trapezoid Area Calculator
Area of a trapezoid from its two parallel sides and height — with the midsegment length and, if you add the legs, the perimeter.
Midpoint Calculator
The point exactly halfway between two points — with the distance between them and the slope of the line through them as checks.
Arithmetic Series Calculator
The sum, last term and average of an arithmetic series from its first term, common difference and number of terms.