The trapezoidal rule is a numerical integration method for estimating the area under a curve (a definite integral) when you only have a set of data points, or when the function is too complex to integrate algebraically. This calculator takes your interval width h and a list of equally-spaced y-values and applies the trapezoidal rule formula directly, giving you an instant numerical estimate of the integral — useful for students checking numerical methods homework, and for anyone estimating an area or total from experimental or tabulated data (for example, sensor readings taken at regular time intervals).
Unlike exact symbolic integration, the trapezoidal rule works purely from the numbers you give it: it approximates the curve between each pair of adjacent points with a straight line (forming a trapezoid) rather than the true curve, which makes it fast and simple but introduces a small, predictable error. This makes it a core technique in numerical methods courses, engineering data analysis, and any situation where you need a 'good enough' area estimate from discrete measurements rather than a continuous formula.
The trapezoidal rule formula
Given equally-spaced y-values y0, y1, y2, ..., yn with constant interval width h between each x-value, the trapezoidal rule estimates the definite integral as: Integral ≈ (h/2) × (y0 + 2y1 + 2y2 + ... + 2y(n-1) + yn). In words: add the first and last y-value once, add all the 'middle' y-values twice, then multiply the whole sum by half the interval width. This comes from approximating the area under the curve between each consecutive pair of points as a trapezoid, whose area is (h/2) × (height1 + height2), and summing all those trapezoid areas together.
Accuracy and error characteristics
The trapezoidal rule tends to slightly overestimate the area under a curve that is concave up (bulging downward, like a smile) and slightly underestimate the area under a curve that is concave down (bulging upward, like a frown), because straight-line segments cut across the curve rather than following it exactly. The error generally shrinks as you use more, closer-together points (a smaller h) — halving h roughly quarters the error, since the trapezoidal rule's error is proportional to h². For curves with significant curvature, Simpson's rule (which fits parabolas instead of straight lines) is typically more accurate for the same number of points.
Frequently asked questions
Integral ≈ (h/2) × (y0 + 2y1 + 2y2 + ... + 2y(n-1) + yn), where h is the constant spacing between x-values and y0...yn are the function values at each point.
At least two (which gives a single trapezoid), but more equally-spaced points generally produce a more accurate estimate of the true area under the curve.
No — it's an approximation. It's exact only for functions that are genuinely straight lines between your data points; for curved functions it carries a small error that shrinks as you add more points.
The trapezoidal rule approximates the curve between points with straight lines, while Simpson's rule fits a parabola through each set of three points, which is usually more accurate for smooth curves given the same number of points.
Yes, this standard (and simplest) version of the formula assumes equal spacing h between every x-value; unequal spacing requires a more general version of the formula.