Trapezoidal Rule Calculator — Approximate Definite Integrals Online

Use our free trapezoidal rule calculator to estimate integrals numerically. Supports function expressions and data table input with detailed step-by-step breakdowns and composite trapezoidal rule approximations.

Verified Formula Instant Results Privacy First

Trapezoidal Rule Calculator

Approximate a definite integral using the composite trapezoidal rule. Choose function input or table input mode.

Examples:

Enter (x, f(x)) data pairs. X-values should be in ascending order. Supports equal or unequal spacing.

#xf(x)
Enter a function or table data and click Calculate Integral to see the approximation.

Trapezoidal Rule Formula Explained

The composite trapezoidal rule approximates the definite integral of a function by dividing the area under the curve into trapezoids and summing their areas. It is one of the most widely used numerical integration techniques.

ab f(x) dx ≈ (h / 2) [ f(x₀) + 2 f(x₁) + 2 f(x₂) + … + 2 f(xn−1) + f(xn) ]
where h = (b − a) / n,   xi = a + i·h   for i = 0, 1, …, n

Variable Definitions

  • a — Lower limit of integration (starting x-value)
  • b — Upper limit of integration (ending x-value)
  • n — Number of subintervals (trapezoids)
  • h — Width of each subinterval: (b − a) / n
  • xi — The i-th x-value: xi = a + i·h
  • f(xi) — Function value at each grid point

The trapezoidal rule is exact for polynomials of degree 1 or less (linear functions). For other functions, accuracy improves as n increases, with error proportional to 1/n².

How to Calculate Using the Trapezoidal Rule

Follow these steps to approximate a definite integral using the composite trapezoidal rule:

  1. Determine h — Calculate the subinterval width: h = (b − a) / n.
  2. Generate x-values — Compute x₀ = a, x₁ = a + h, x₂ = a + 2h, …, xn = b.
  3. Evaluate f(x) at each xi — Compute the function value at every grid point.
  4. Apply the formula — Sum f(x₀) + 2f(x₁) + 2f(x₂) + … + 2f(xn−1) + f(xn).
  5. Multiply by h/2 — The final approximation is (h/2) × the sum from step 4.

For table input with potentially uneven spacing, the piecewise formula Σ (xi+1 − xi)(f(xi) + f(xi+1))/2 is applied across each segment.

Trapezoidal Rule Calculation Examples

Example 1: ∫ x² dx on [0, 2] with n = 4

h = (2 − 0) / 4 = 0.5. x-values: 0, 0.5, 1.0, 1.5, 2.0. f(x) = x² gives: 0, 0.25, 1.0, 2.25, 4.0.

Sum = 0 + 2(0.25) + 2(1.0) + 2(2.25) + 4.0 = 11.0
Result = (0.5/2) × 11.0 = 2.75   (Exact: 8/3 ≈ 2.6667)

Example 2: ∫ sin(x) dx on [0, π] with n = 6

h = π/6 ≈ 0.5236. With 6 subintervals, the trapezoidal rule gives approximately 1.9541 (exact value: 2.0). Increasing n improves accuracy.

Example 3: Table Input with Uneven Spacing

Given points (0, 1), (1, 3), (3, 7), (5, 11): apply the piecewise formula for each segment.

Area ≈ (1−0)(1+3)/2 + (3−1)(3+7)/2 + (5−3)(7+11)/2 = 2 + 10 + 18 = 30

Real-World Applications of the Trapezoidal Rule

  • Engineering: Calculating cross-sectional areas, volumes of irregular shapes, and structural load distributions.
  • Physics: Computing work done by variable forces, impulse from force-time graphs, and center of mass.
  • Surveying: Estimating land areas using trapezoidal rule for area calculation from offset measurements.
  • Pharmacokinetics: Calculating AUC (area under the curve) for drug concentration-time data in clinical studies.
  • Economics: Computing consumer and producer surplus, and total welfare from supply-demand curves.
  • Environmental Science: Estimating total pollutant discharge from flow rate data over time.
  • Signal Processing: Numerical integration of sampled signals for energy and power calculations.

People Also Ask

The composite trapezoidal rule formula is ∫[a,b] f(x)dx ≈ (h/2)[f(x₀) + 2∑f(xᵢ) + f(xₙ)] where h = (b−a)/n, x₀ = a, and xₙ = b. For a single segment (n=1), it simplifies to (b−a)/2 × [f(a) + f(b)], which is the area of a single trapezoid.
The trapezoidal rule uses linear interpolation between points (forming trapezoids), while Simpson's rule uses quadratic interpolation (fitting parabolas). Simpson's rule generally provides better accuracy with error proportional to 1/n⁴ versus 1/n² for the trapezoidal rule, but requires an even number of subintervals.
The error bound is |Error| ≤ (K(b−a)³)/(12n²), where K = max|f''(x)| on [a,b]. To guarantee a desired accuracy ε, choose n ≥ √(K(b−a)³/(12ε)). This formula helps determine the minimum number of subintervals needed for a target precision.
Yes, the trapezoidal rule works with tabulated data. For equally spaced data, use the standard formula. For uneven spacing, apply the piecewise formula Σ (xᵢ₊₁ − xᵢ)(f(xᵢ) + f(xᵢ₊₁))/2 across each consecutive pair of points. This calculator supports both approaches.
AUC (Area Under the Curve) calculation using the trapezoidal rule is standard in pharmacokinetics for measuring total drug exposure. It applies the trapezoidal rule to plasma concentration-time data, summing the areas of trapezoids formed between consecutive time points. This method is widely used in bioequivalence studies.

Frequently Asked Questions

The minimum is n = 1, which gives the simple trapezoidal rule using only the endpoints. However, more subintervals yield better accuracy. For smooth functions, n = 10 to 100 often provides good results. Use the error bound formula to determine n for a specific accuracy requirement.
No, this calculator is designed for proper definite integrals with finite bounds and well-defined function values throughout the interval. For improper integrals (infinite bounds or singularities), specialized techniques like limit approaches or transformation methods are required.
You can use standard math notation: +, -, *, /, ^ for exponents, parentheses, and functions like sin(x), cos(x), tan(x), exp(x), ln(x), log(x), sqrt(x), abs(x). Constants pi and e are also supported. Use x as the variable. Example: sin(x)^2 + exp(-x).
Accuracy depends on the smoothness of f(x) and the number of subintervals n. The error decreases proportionally to 1/n². Doubling n roughly quarters the error. For functions with large second derivatives, more subintervals are needed. The rule is exact for linear functions.
Yes, the trapezoidal rule for volume calculation in surveying uses cross-sectional areas at regular intervals. By treating cross-sectional areas as f(x) values and applying the trapezoidal rule, you can estimate earthwork volumes, reservoir capacities, and excavation quantities.
The single application (n=1) uses one trapezoid spanning the entire interval [a,b]. The composite trapezoidal rule divides [a,b] into n subintervals and applies the rule to each, then sums the results. The composite rule provides much better accuracy for the same function.

Trapezoidal Rule Glossary

Numerical Integration

Approximating definite integrals using discrete function evaluations; also called numerical quadrature.

Composite Trapezoidal Rule

Applying the trapezoidal rule to multiple subintervals and summing the results for improved accuracy.

Subinterval Width (h)

The constant spacing between x-values: h = (b − a) / n. Smaller h generally yields better accuracy.

Error Bound

A theoretical upper limit on the approximation error: |Error| ≤ (K(b−a)³)/(12n²) where K = max|f''(x)|.

AUC (Area Under Curve)

The total area between a function and the x-axis, commonly estimated using the trapezoidal rule in pharmacokinetics.

Riemann Sum

A general method for approximating integrals by summing rectangle areas; the trapezoidal rule is a refinement.

Simpson's Rule

A higher-order numerical integration method using quadratic interpolation, generally more accurate than the trapezoidal rule.

Midpoint Rule

A numerical integration method using rectangle heights at subinterval midpoints; often complementary to the trapezoidal rule.

Editorial Review & Methodology

This trapezoidal rule calculator was built and reviewed by the NumbrWiz Editorial Team. The trapezoidal rule is a standard numerical integration technique taught in calculus and numerical analysis courses, verified against authoritative textbooks including Stewart's Calculus, Burden & Faires' Numerical Analysis, and standard engineering mathematics references.

  • Formula verification: Cross-checked against multiple calculus and numerical methods sources.
  • Edge case testing: Tested with polynomial, trigonometric, exponential, and rational functions across varied intervals and subinterval counts.
  • Table mode validation: Verified with both equal and unequal spacing scenarios against manual calculations.

Transparency note: All calculations run client-side in your browser. No data is ever collected, stored, or transmitted. Results are for educational purposes; verify critical calculations independently, especially for engineering and scientific applications.

Page last reviewed: May 2026 · NumbrWiz Editorial Team