# What does the trapezoidal rule give?

Approximates the definite integral of f(x) from a to b with the trapezoidal rule in n subintervals, with every point, the midpoint rule and Simpson’s rule for comparison.

- Page: https://www.acalculator.org/math/trapezoidal-rule-calculator
- JSON spec: https://www.acalculator.org/math/trapezoidal-rule-calculator.json
- Version: 6cde2fba25d9

## Default answer

Example with the default inputs (f(x) x^2, Lower limit (a) 0, Upper limit (b) 1, Subintervals (n) 4): The trapezoidal rule with n = 4 gives 0.34375 for the integral of x^2 from 0 to 1.

## Inputs

| Key | Label | Description |
| --- | --- | --- |
| f | f(x) | The function to integrate, in x, for example x^2 or sqrt(1 + x^2). |
| a | Lower limit (a) | Where the interval starts. |
| b | Upper limit (b) | Where the interval ends; it may be below a. |
| n | Subintervals (n) | How many equal subintervals (trapezoids), from 1 to 1,000. |

## Outputs

| Key | Label | Description |
| --- | --- | --- |
| trapezoid | Trapezoidal rule Tₙ | Δx/2 × (f(x₀) + 2f(x₁) + … + 2f(xₙ₋₁) + f(xₙ)). |
| dx | Δx | (b − a) ÷ n, exactly from the typed decimals. |
| midpoint | Midpoint rule Mₙ | Δx × (f(m₁) + … + f(mₙ)), where mᵢ is the middle of each subinterval. |
| simpson | Simpson’s rule Sₙ | Δx/3 × (f(x₀) + 4f(x₁) + 2f(x₂) + … + 4f(xₙ₋₁) + f(xₙ)); for even n only. |
| sum | Weighted sum | f(x₀) + 2f(x₁) + … + 2f(xₙ₋₁) + f(xₙ), before × Δx/2. |

## Method

Δx = (b − a) ÷ n; xᵢ = a + iΔx; Tₙ = Δx/2 × (f(x₀) + 2f(x₁) + … + 2f(xₙ₋₁) + f(xₙ)); Mₙ = Δx × Σ f(a + (i − ½)Δx); Sₙ = Δx/3 × (f(x₀) + 4f(x₁) + 2f(x₂) + … + 4f(xₙ₋₁) + f(xₙ)).

## Assumptions

- f must have a real value at every point used (and at every midpoint).
- xᵢ comes exactly from the typed decimals; f and the sums are in double precision.
- 1 to 1,000 subintervals; a and b from −10⁹ to 10⁹, and different. Simpson’s rule needs an even n.

## Worked examples

1. f = x^2, a = 0, b = 1, n = 4 gives trapezoid = 0.34375, midpoint = 0.328125, dx = 0.25, simpson = 0.333333. Source: OpenStax, Calculus Volume 2, §3.6 Numerical Integration (midpoint rule, trapezoidal rule, Simpson’s rule; Examples 3.39, 3.41 and 3.45). https://openstax.org/books/calculus-volume-2/pages/3-6-numerical-integration (T₄ = 11/32, M₄ = 21/64).
2. f = x^3, a = 0, b = 1, n = 2 gives simpson = 0.25, trapezoid = 0.3125. Source: OpenStax, Calculus Volume 2, §3.6 Numerical Integration (midpoint rule, trapezoidal rule, Simpson’s rule; Examples 3.39, 3.41 and 3.45). https://openstax.org/books/calculus-volume-2/pages/3-6-numerical-integration (S₂ = 1/4).
3. f = sqrt(1 + x^2), a = 1, b = 4, n = 6 gives midpoint = 8.143073, simpson = 8.145944, trapezoid = 8.151209. Source: OpenStax, Calculus Volume 2, §3.6 Numerical Integration (midpoint rule, trapezoidal rule, Simpson’s rule; Examples 3.39, 3.41 and 3.45). https://openstax.org/books/calculus-volume-2/pages/3-6-numerical-integration (M₆ ≈ 8.1431, S₆ ≈ 8.14594).

## FAQ

### What is the trapezoidal rule?

It approximates the area under y = f(x) from a to b by n trapezoids of equal width Δx = (b − a) ÷ n: Tₙ = Δx/2 × (f(x₀) + 2f(x₁) + … + 2f(xₙ₋₁) + f(xₙ)). It is the average of the left and right Riemann sums.

### How do I use the trapezoidal rule by hand?

For ∫₀¹ x² dx with n = 4: Δx = 0.25, the points are 0, 0.25, 0.5, 0.75, 1 and f is 0, 1/16, 1/4, 9/16, 1. T₄ = 0.125 × (0 + 2/16 + 1/2 + 18/16 + 1) = 11/32 = 0.34375. The exact value is 1/3.

### Why do the end points count once and the others twice?

Each inner point is the right side of one trapezoid and the left side of the next, so its height is used twice. The two end points belong to one trapezoid each.

### Is the trapezoidal rule an overestimate or an underestimate?

For a function that curves up (concave up) the trapezoids sit above the curve and Tₙ is too large; for one that curves down it is too small. For x² on [0, 1], T₄ = 0.34375 is above the exact 1/3.

### How does it compare with the midpoint rule and Simpson’s rule?

The midpoint rule uses the height at the middle of each subinterval; its error bound is half the trapezoidal one. Simpson’s rule fits parabolas and is usually far more accurate: S₄ for x² on [0, 1] is exactly 1/3.

### How many subintervals should I use?

More subintervals give a smaller error: the trapezoidal error bound shrinks with 1/n², so doubling n cuts it to a quarter. The calculator allows up to 1,000.

## Sources

- OpenStax, Calculus Volume 2, §3.6 Numerical Integration (midpoint rule Mₙ, trapezoidal rule Tₙ, Simpson’s rule Sₙ, error bounds; Examples 3.39 M₄ = 21/64, 3.40 M₆ ≈ 8.1431, 3.41 T₄ = 11/32, 3.45 S₂ = 1/4, 3.46 S₆ ≈ 8.14594). https://openstax.org/books/calculus-volume-2/pages/3-6-numerical-integration (retrieved 2026-10-02)
