Trapezoidal Rule Calculator screenshot

Trapezoidal Rule Calculator

Approximate a definite integral with the trapezoidal rule, printing n, the step size and the estimate.

Privacy First
0 Runs
Updated 2026-11-22
No upload
Instant
No signup

Trapezoidal Rule Calculator

Approximate a definite integral with the trapezoidal rule, printing n, the step size and the estimate.

How this page computes

The page sums the endpoint values with half weight and the interior values with full weight, then multiplies by the step. The output names n and h so the grid is never implicit.

The calculation runs entirely in this browser tab; nothing is uploaded.

The page applies the trapezoidal rule to a definite integral and prints the estimate, n and h. Worked example: x^2 on [0, 1] with n = 100 gives 0.33335.

Each subinterval is a trapezoid rather than a rectangle, so a linear integrand is integrated exactly. The page states the O(h^2) error order and the grid it used instead of implying an exact answer.

How to use the Trapezoidal Rule Calculator

Enter the integrand in x, set a, b and the number of intervals n, then press Run. The first line is the estimate and the second is h.

The endpoint values count once with weight one half, and every interior value counts once. That is the composite trapezoidal rule, and the printed h is (b - a) / n.

The composite trapezoidal rule

The rule replaces the integrand on each subinterval by the straight line through its endpoints. The area of that trapezoid is h times the average of the two endpoint values.

For a twice-differentiable integrand the error shrinks like h squared, so doubling n cuts it by about four. The page names that order rather than claiming a tolerance it did not verify.

What to Expect

Best for

  • Checking a trapezoidal-rule exercise
  • Seeing why a linear integrand is exact
  • Comparing n values at a fixed integrand

Not ideal for

  • An adaptive estimate with a tolerance
  • A symbolic antiderivative
  • Integrands with a singularity inside the interval

What this tool keeps

  • n, h and the composite estimate

What may need cleanup

  • Round the estimate according to the O(h^2) error, not to the printed digits

Common errors

  • n below 1 is refused
  • A non-finite endpoint or interior sample is refused

Example use cases

  • Estimate the integral of x^2 on [0, 1]
  • See that a line integrates exactly

Sample input

x^2

Sample output

trapezoidal rule for x^2 on [0, 1] with n = 100: 0.33335 h = 0.01; error is O(h^2) for a smooth integrand

Who this is for

  • Students learning numerical integration
  • Readers checking a hand-computed table

Frequently asked questions

Why is a linear function exact?

The trapezoidal rule replaces the integrand by a straight line on each subinterval. If the integrand already is a straight line, the replacement is the function itself, so the area is exact for any n.

How does n affect the error?

The error is O(h^2), and h is (b - a) / n, so doubling n reduces the error by roughly a factor of four for a smooth integrand. The page prints h so that scaling is visible.

Is this the same as the average of left and right sums?

Yes for a uniform grid. The trapezoidal estimate equals the average of the left and right Riemann sums, which is another way to see why it is more accurate than either alone.

Is anything uploaded?

Nothing is uploaded. The integrand is evaluated and the trapezoids are summed in this browser tab, and reloading the page discards the input and the estimate.

Developer program

Build custom tools for your store

Join the SDK program to create useful ecommerce utilities for your store.