Use the Trapezoidal Rule Calculator to estimate a definite integral from data points.
If you have function values at equally spaced x-values, the trapezoidal rule approximates the area under the curve. Enter y0, yn, the step size h, and the number of intervals n (or the full set of y-values) to compute the integral quickly.
What the Trapezoidal Rule Calculator computes
The trapezoidal rule is a numerical method that approximates the area under a curve by replacing each small section with a trapezoid. When x-values are equally spaced, the approximation uses a weighted sum of the y-values.
For a definite integral from a to b with n intervals, the step size is h = (b – a) / n. The trapezoidal rule then estimates:
Core formula (equally spaced points)
Let the points be x0, x1, …, xn with spacing h, and let yi = f(xi). The trapezoidal rule is:
∫ab f(x) dx ≈ (h/2) · [y0 + 2(y1 + y2 + … + y(n−1)) + yn]
How the weights work
- Endpoints (y0 and yn) have weight 1.
- Interior points have weight 2.
- This reflects how trapezoids share interior edges.
Inputs you need (and why)
To use the trapezoidal rule, you need a set of y-values at equally spaced x-values. The calculator below supports two common workflows: (1) provide all y-values, or (2) provide only endpoints and the step size with a simplified interior handling option.
In most real problems, you will have measured or computed y-values for each x. That is the most reliable way to use the method.
Step size h
h is the constant spacing between consecutive x-values. If you know the x-range and the number of intervals, use h = (b − a)/n. If you already know h, you can skip computing it.
Number of intervals n
n is how many sub-intervals split the range from a to b. If you have n + 1 y-values, that matches the trapezoidal rule exactly.
Accuracy: when the trapezoidal rule works best
The trapezoidal rule is most accurate when the function is smooth and does not curve sharply within each interval. The error decreases as you use smaller step sizes (larger n).
As a rule of thumb:
- If your curve is nearly linear over each interval, the approximation is very good.
- If the curve bends strongly, you need more intervals to reduce error.
- For noisy measurements, consider smoothing or using smaller h.
Practical examples
Example 1: Area from sampled measurements
Suppose you measure a signal at times every 0.5 seconds and want the total “accumulated area” over 10 seconds. You collect y values (signal magnitude) at each time point and use the trapezoidal rule to approximate the integral.
This is common in physics, engineering, and data analysis when you have discrete samples but need a continuous quantity.
Example 2: Estimating work from a force curve
In mechanics, work is the integral of force over distance: W = ∫ F(x) dx. If your force is measured at equal distance steps, you can apply the trapezoidal rule to estimate work without solving a complicated model.
The result is an area-like sum with the correct unit structure: if force is in newtons and distance is in meters, the integral is in joules.
Step-by-step: how to use the Trapezoidal Rule Calculator
- Choose your workflow: enter all y-values (recommended) or use endpoint-based entry if applicable.
- Set the step size h or enter a, b, and let the calculator compute it.
- Provide n (or let it match the number of y-values).
- Click Calculate to get the estimated integral.
- Check units: ensure your y-units match the intended integral units (y·x).
Common mistakes to avoid
- Unequal spacing: the trapezoidal rule assumes equal spacing in x. If spacing changes, you need a different method (or resample).
- Mismatched counts: if you enter n intervals, you must have n + 1 y-values.
- Unit confusion: the integral’s unit is (unit of y) × (unit of x).
- Wrong sign: if y-values go negative, the integral will reflect that (area below the axis subtracts).
Frequently Asked Questions
What is the trapezoidal rule used for?
The trapezoidal rule estimates the value of a definite integral using tabulated function values. It works by splitting the interval into equal parts and approximating each part with a trapezoid. The result is a weighted sum of the y-values that represents the area under the curve.
Do I need equally spaced x-values?
Yes. The standard trapezoidal rule assumes constant step size h between consecutive x-values. If your x-spacing is not equal, the trapezoidal rule formula with a single h can produce incorrect results. Use a method for uneven spacing or resample to equal steps.
How do I choose the number of intervals n?
Choose n so the step size h is small enough that the curve looks nearly linear between points. If you can refine the data, increase n and compare results. A big change indicates the step is too large and the approximation needs refinement for accuracy.
What does the integral unit become?
The integral’s unit is the product of the y-unit and the x-unit. For example, if y is force in newtons and x is distance in meters, the integral gives work in joules. Always verify units before interpreting the numeric result in context.
Is the trapezoidal rule accurate enough for engineering work?
Often, yes when the function is smooth and you use sufficiently small step sizes. For engineering calculations, you can test accuracy by recomputing with a finer n. If results converge, the trapezoidal rule is typically adequate for practical decision-making and estimation.



