What this calculator does
The trapezoidal rule approximates the area under a curve, or a definite integral, by joining consecutive data points with straight lines and adding up the area of the resulting trapezoids. It is one of the most common numerical integration methods, useful whenever the underlying function is not known in a form that can be integrated directly, or when all you have to work with is a set of measured or sampled points.
This is a different trapezoidal calculation from finding the plain area of a trapezoid shape: the trapezoidal rule uses trapezoids as a tool for approximating the area under any curve made of several data points, not the area of one single four-sided figure. Enter matching x and y values, in increasing order of x, and the total approximate area comes out along with the contribution from each subinterval.
The formula
For each pair of consecutive points, the trapezoidal rule treats the curve between them as a straight line and calculates the area of the trapezoid formed with the x-axis: the width of that interval, (x[i+1] − x[i]), times the average of the two y-values, (y[i] + y[i+1]) ÷ 2. Adding up every such trapezoid gives the total approximate area.
| Term | Meaning |
|---|---|
| x, y values | The coordinates of each data point, in increasing order of x. |
| Subinterval | The gap between one x value and the next. |
| Trapezoid area | The area contributed by a single subinterval: width × average height. |
| Definite integral | The exact area under a curve between two points, which the trapezoidal rule approximates. |
The inputs explained
| Field | What to enter |
|---|---|
| x values (comma separated, increasing) | The x-coordinates of each data point, separated by commas, listed in increasing order. |
| y values (comma separated, same order) | The corresponding y-coordinates, in the same order as the x values. Both lists need at least two matching pairs. |
When to use it
Estimating area under a curve from sampled data
Sensor readings, experimental measurements or any other data collected at intervals can be integrated numerically this way, without needing a formula for the underlying curve at all.
Approximating a definite integral by hand or for a check
Sampling a known function at several x values and applying the trapezoidal rule gives a quick numerical check against a definite integral worked out analytically.
Comparing accuracy at different levels of detail
Using more, closely spaced data points generally brings the trapezoidal approximation closer to the true area, since each individual straight-line segment then has to bend less to follow the real curve.
Worked examples
Every figure in the tables below is produced by this page’s own calculator at build time, so the numbers and the tool always agree. Select any row to load that scenario.
Trapezoidal rule area for different curve shapes
The same six evenly spaced x values, with the y values changing to trace out different curve shapes.
| Y values | Approximate area under the curve | Number of subintervals |
|---|---|---|
| 0, 1, 4, 9, 16, 25 | 42.500 | 5 |
| 5, 5, 5, 5, 5, 5 | 25.000 | 5 |
| 0, 2, 0, 2, 0, 2 | 5.000 | 5 |
| 0, 1, 2, 3, 4, 5 | 12.500 | 5 |
How area scales with the spacing between x values
The same five y values, with the spacing of the x values stretched or compressed.
| X values | Approximate area under the curve |
|---|---|
| 0, 0.5, 1, 1.5, 2 | 5.000 |
| 0, 1, 2, 3, 4 | 10.000 |
| 0, 2, 4, 6, 8 | 20.000 |
| 0, 5, 10, 15, 20 | 50.000 |
Questions
Is the trapezoidal rule the same as finding the area of a trapezoid shape?
No. Finding the area of a single trapezoid shape uses ½ × (a + b) × h from its two parallel sides and height. The trapezoidal rule instead adds up many small trapezoids to approximate the area under a curve made of several data points, which is a numerical integration method, not a shape-area formula.
How accurate is the trapezoidal rule?
It is exact for straight-line data and close to exact for gently curving data with enough points. For curves that bow noticeably between points, it tends to slightly overestimate the area under a convex curve and slightly underestimate it under a concave one, an error that shrinks as more, closer-together points are used.
What if my x values are not evenly spaced?
That is fine. Each subinterval is treated on its own, using its own actual width, so unevenly spaced data points are handled correctly without any special adjustment.
What happens if I enter the same number of x and y values but out of order?
The x values must be entered in increasing order for the calculation to make sense, since each step relies on moving from a smaller x to the next larger one. Sort both lists into matching increasing-x order before entering them.
For the plain area of a trapezoid shape rather than the area under a curve, see the area of trapezium calculator. For a straight line's own equation rather than a curve made of points, see the gradient calculator.