Trapezoidal Rule Calculator

Join neighbouring points with straight lines instead of flat tops. Enter f(x), the interval and n to get Tₙ with every trapezoid drawn, the weighted table and the actual error.

Reads as x2x^{2}
Try:

Trapezoid sum with n = 6

9.125

Exact ∫03x2 dx=9\int_{0}^{3} x^{2}\,dx = 9 · error 0.125

0.511.522.5324681012

The formula

T6=Δx2[f(x0)+2f(x1)+⋯+2f(xn−1)+f(xn)],Δx=0.5T_{6} = \frac{\Delta x}{2}\left[f(x_0) + 2f(x_1) + \dots + 2f(x_{n-1}) + f(x_n)\right],\quad \Delta x = 0.5
Each slice
iisample xxavg heightarea
000.1250.0625
10.50.6250.3125
211.6250.8125
31.53.1251.5625
425.1252.5625
52.57.6253.8125

All five methods, n = 6

MethodEstimateError
Left6.875-2.13
Right11.3752.38
Midpoint8.9375-0.0625
Trapezoid9.1250.125
Simpson90

Still stuck? Ask the tutor

An AI tutor reads the problem and steps above and explains them in plain words. It can make mistakes, so check it against the worked steps.

The trapezoidal rule formula

Tn=Δx2[f(x0)+2f(x1)+2f(x2)+⋯+2f(xn−1)+f(xn)]T_n = \frac{\Delta x}{2}\left[f(x_0) + 2f(x_1) + 2f(x_2) + \cdots + 2f(x_{n-1}) + f(x_n)\right]

Each slice is a trapezoid whose area is the average of its two side heights times the width, f(xi−1)+f(xi)2Δx\frac{f(x_{i-1}) + f(x_i)}{2}\Delta x. Adding them, every interior point is counted twice, which gives the 1, 2, 2, …, 2, 1 weights.

The trapezoidal rule is exactly the average of the left and right Riemann sums: Tn=Ln+Rn2T_n = \frac{L_n + R_n}{2}.

Error bound: if ∣f′′(x)∣≤K|f''(x)| \le K on [a,b][a,b], then ∣ET∣≤K(b−a)312n2|E_T| \le \frac{K(b-a)^3}{12n^2}. Doubling nn cuts the error by about 4.

For a concave-up function the straight tops lie above the curve, so TnT_n overestimates. For concave-down it underestimates.

Compare all five methods side by side on the Riemann sum calculator, or try another single rule: Simpson’s rule, Midpoint rule, Left Riemann sum, Right Riemann sum.

Questions students ask

What is the trapezoidal rule formula?

Tn=Δx2[f(x0)+2f(x1)+⋯+2f(xn−1)+f(xn)]T_n = \frac{\Delta x}{2}[f(x_0) + 2f(x_1) + \cdots + 2f(x_{n-1}) + f(x_n)] with Δx=b−an\Delta x = \frac{b-a}{n} and xi=a+iΔxx_i = a + i\Delta x.

How do I find the error bound for the trapezoidal rule?

Find KK, the largest value of ∣f′′(x)∣|f''(x)| on [a,b][a,b]; then ∣ET∣≤K(b−a)312n2|E_T| \le \frac{K(b-a)^3}{12n^2}. To guarantee an error below ε\varepsilon, choose n≥K(b−a)312εn \ge \sqrt{\frac{K(b-a)^3}{12\varepsilon}}.

Is the trapezoidal rule more accurate than the midpoint rule?

Usually not. For smooth functions the midpoint error is about half the trapezoidal error and of the opposite sign, which is why Simpson’s rule, S2n=2Mn+Tn3S_{2n} = \frac{2M_n + T_n}{3}, is so accurate.

Can I use the trapezoidal rule with a table of data?

Yes, with equally spaced x-values: multiply Δx2\frac{\Delta x}{2} by (first value + last value + twice every value in between). For unequal spacing, add each trapezoid separately.

Does the trapezoidal rule over- or underestimate?

Overestimates where the graph is concave up (f′′>0f'' > 0) and underestimates where it is concave down.