1 Definition and basic idea
The trapezoidal rule is a numerical method for estimating a definite integral by replacing the graph of a function with a sequence of straight-line segments. Over each subinterval, the area under the curve is approximated by the area of a trapezoid rather than by the exact curved shape. This makes the method easy to apply and especially useful when no simple antiderivative is available.
At its core, the method uses sampled values of the integrand at selected points. The more finely the interval is divided, the closer the trapezoidal approximation usually becomes to the true integral. For smooth functions, the method provides a practical balance between simplicity and accuracy.
1.1 Geometric interpretation
Geometrically, the trapezoidal rule estimates the area under a curve by joining adjacent points on the graph with straight line segments. The region beneath each segment and above the horizontal axis forms a trapezoid, whose area can be computed directly.
This interpretation is intuitive because it replaces a curved boundary with a polygonal one. On sufficiently small subintervals, a smooth curve is often well approximated by a line segment, so the resulting trapezoidal area can be close to the actual area under the curve.
1.2 Riemann-sum perspective
From the viewpoint of Riemann sums, the trapezoidal rule is a refined averaging method. Instead of using only left-endpoint or right-endpoint function values to form rectangles, it averages the contributions from both ends of each subinterval.
This makes the method more symmetric than a one-sided rectangle rule. The use of endpoint averages improves accuracy for many functions, especially when the graph changes gradually across the interval.
1.3 Relation to linear interpolation
The trapezoidal rule can also be understood as integrating a piecewise linear interpolant of the function. On each subinterval, the function is replaced by the straight line passing through the two endpoint values, and that linear approximation is then integrated exactly.
This connection is important because it explains why the method works well for smooth functions. When the function behaves nearly linearly over small intervals, the area under the interpolating line closely matches the true area under the curve.
2 Formula
The trapezoidal rule has a simple closed-form expression in both its single-interval and composite versions. The formula depends only on the function values at the endpoints of the interval or at the nodes of a partition.
2.1 Single-interval trapezoidal rule
For a function \(f\) on an interval \([a,b]\), the basic trapezoidal approximation is
\[ \int_a^b f(x)\,dx \approx \frac{b-a}{2}\bigl(f(a)+f(b)\bigr). \]
This formula treats the graph of \(f\) between \(a\) and \(b\) as a straight line segment. The factor \((b-a)/2\) reflects the average of the endpoint heights multiplied by the interval width.
2.2 Composite trapezoidal rule
When the interval is divided into smaller parts, the rule is applied to each subinterval and the results are added together. This composite form is the version most often used in practice because it improves accuracy without making the method significantly more complicated.
2.2.1 Equal subintervals
If \([a,b]\) is partitioned into \(n\) equal subintervals of width \(h=(b-a)/n\), with nodes \(x_i=a+िह\), then the composite trapezoidal rule becomes
\[ \int_a^b f(x)\,dx \approx \frac{h}{2}\Bigl(f(x_0)+2\sum_{i=1}^{n-1} f(x_i)+f(x_n)\Bigr). \]
Interior points appear twice because each one serves as an endpoint for two neighboring trapezoids.
2.2.2 Weighted endpoint terms
The weighting structure reflects the geometry of the partition. The first and last nodes contribute once, while every interior node contributes twice. This pattern is characteristic of the trapezoidal rule and distinguishes it from formulas that rely on midpoint or central sample values.
These weights make the method computationally efficient, since the same function value is reused in adjacent subintervals. In iterative settings, this structure can reduce the number of new function evaluations required.
2.3 Notation for step size
The quantity \(h\) is usually called the step size or mesh width. It measures the spacing between consecutive sample points in an equally spaced partition.
Smaller values of \(h\) generally improve the approximation, provided the function is well behaved. However, reducing \(h\) also increases the number of subintervals, so there is a practical trade-off between accuracy and computational effort.
3 Derivation
The trapezoidal rule can be derived in several equivalent ways. These derivations illuminate why the formula has its particular form and why it is closely tied to linear approximation.
3.1 From the area of a trapezoid
A trapezoid is a quadrilateral with one pair of parallel sides. Its area equals the average of the two parallel side lengths multiplied by the distance between them. If the heights at the ends of an interval are \(f(a)\) and \(f(b)\), then the area of the corresponding trapezoid is
\[ \frac{b-a}{2}\bigl(f(a)+f(b)\bigr). \]
This direct geometric argument yields the single-interval rule immediately. The composite formula follows by applying the same reasoning repeatedly on each subinterval.
3.2 From interpolation of the integrand
Another derivation begins by approximating \(f(x)\) with a linear interpolant \(p(x)\) satisfying \(p(a)=f(a)\) and \(p(b)=f(b)\). Since \(p(x)\) is linear, its integral over \([a,b]\) is exactly the area of the trapezoid formed by its endpoints.
This approach shows that the trapezoidal rule is exact for the best linear approximation on the interval. It also clarifies the link between numerical integration and polynomial interpolation.
3.3 From the Newton-Cotes family
The trapezoidal rule is the first nontrivial member of the Newton-Cotes formulas, a family of quadrature rules based on integrating interpolating polynomials at equally spaced nodes. In this family, the integrand is replaced by a polynomial passing through selected sample points.
For the trapezoidal rule, the interpolating polynomial has degree one. More elaborate Newton-Cotes formulas use higher-degree polynomials and more nodes, but they may introduce greater complexity and, in some cases, numerical instability.
4 Error analysis
Error analysis measures the difference between the true integral and its numerical approximation. For the trapezoidal rule, the size of the error depends strongly on the smoothness of the function and the fineness of the partition.
4.1 Local truncation error
On a single subinterval, the trapezoidal rule is exact for linear functions but not for most curved functions. If the function has a continuous second derivative, the local error on one interval is proportional to the square of the interval width times the curvature.
This means that the approximation improves rapidly as the subintervals become smaller. The term “truncation error” reflects the fact that the true function is truncated to a linear model on each piece.
4.2 Global error of the composite rule
For the composite rule on \(n\) equal subintervals, the total error typically decreases as the square of the step size. In asymptotic form, the global error is often described as \(O(h^2)\) for sufficiently smooth functions.
This second-order convergence makes the method substantially better than simple one-sided rectangle rules, whose errors usually decrease only linearly with \(h\). The global error results from the accumulation of local errors across all subintervals.
4.3 Dependence on the second derivative
The second derivative of the function plays a central role in the error estimate because it measures curvature. A function with small curvature is well suited to the trapezoidal rule, while a function with rapidly changing slope may require a finer partition.
If the second derivative is large in magnitude over part of the interval, the local linear approximation can deviate more strongly from the true graph. This is why smooth, gently varying functions are often approximated more accurately than sharply bent ones.
4.4 Error bounds
| When \(f''(x)\) is bounded on \([a,b]\), the error of the composite trapezoidal rule can be bounded in terms of the maximum of \( | f''(x) | \) and the step size \(h\). Such bounds provide a practical way to estimate the needed mesh refinement for a desired level of accuracy. |
|---|
Error bounds are especially useful in applications, since they turn the abstract convergence behavior into a concrete planning tool. They allow users to choose a partition fine enough to meet an accuracy target without excessive computation.
5 Special cases
Certain functions exhibit particularly simple behavior under the trapezoidal rule. These cases help illustrate both its strengths and its limitations.
5.1 Exactness for linear functions
The trapezoidal rule is exact for all linear functions. Since the graph of a linear function is already a straight line, the trapezoid formed by its endpoints matches the actual region under the curve.
This exactness extends to any function that is linear on each subinterval of the partition. In such situations, the composite rule reproduces the integral without error.
5.2 Behavior for convex and concave functions
For convex functions, the graph lies below the chord joining the endpoints of an interval, so the trapezoidal rule tends to overestimate the true integral. For concave functions, the opposite usually occurs, and the method tends to underestimate.
This behavior follows from the geometry of straight-line approximations. The direction of the error depends on whether the curve bends upward or downward relative to the secant line.
5.3 Periodic functions
For periodic functions, especially smooth ones sampled over complete periods, the composite trapezoidal rule can perform remarkably well. In many such cases, errors cancel efficiently across the interval, leading to unusually rapid convergence.
This feature makes the rule attractive in Fourier analysis and related computations. Its effectiveness for periodic smooth data is one reason it remains important in numerical practice.
6 Numerical properties
Beyond accuracy, the trapezoidal rule is valued for several practical numerical characteristics. These include predictable convergence, simple implementation, and modest computational cost.
6.1 Convergence
The method converges to the true integral as the step size tends to zero, provided the function is sufficiently well behaved. For smooth functions, the convergence rate is generally second order.
Although higher-order methods can converge faster, the trapezoidal rule offers a dependable baseline. Its behavior is easy to analyze, which makes it useful both in theory and in applied computation.
6.2 Stability
The trapezoidal rule is numerically stable in the sense that it does not usually amplify small sampling errors dramatically. Because it relies on direct averaging of function values, it avoids some of the oscillatory behavior seen in more complicated interpolation formulas.
This stability is one reason it is commonly used in algorithms that require repeated integration estimates. It is also helpful when the function values are obtained from measured or simulated data.
6.3 Efficiency
The method is efficient because it requires only function evaluations at the chosen nodes and a simple weighted sum. The formula is straightforward to program and inexpensive to compute.
For problems where function evaluation is costly, the reuse of interior sample points in the composite rule is advantageous. The trapezoidal rule is therefore often a practical first choice before more sophisticated methods are considered.
7 Comparison with other methods
The trapezoidal rule is one of several standard numerical quadrature techniques. Its performance is often compared with simpler rectangle rules and higher-order formulas.
7.1 Midpoint rule
The midpoint rule approximates the integral by evaluating the function at the center of each subinterval rather than at the endpoints. It can be more accurate than the trapezoidal rule for certain functions, particularly when the curvature behaves favorably.
Both rules are of comparable simplicity and have similar computational demands. Their error constants differ, so one may outperform the other depending on the function’s shape and the partition used.
7.2 Simpson's rule
Simpson's rule uses quadratic interpolation instead of linear interpolation and often achieves higher accuracy for smooth functions. It typically converges faster than the trapezoidal rule, especially when the integrand is well approximated by parabolas over short intervals.
However, Simpson's rule is somewhat more restrictive and slightly more involved to implement. The trapezoidal rule remains useful when simplicity, robustness, or repeated refinement is more important than maximal order.
7.3 Higher-order quadrature methods
Higher-order quadrature methods extend the interpolation idea to polynomials of greater degree or to more specialized node choices. These methods can achieve much higher accuracy per function evaluation under suitable conditions.
Their added precision comes at the cost of greater complexity and sometimes reduced numerical robustness. The trapezoidal rule is often a good starting point because it is easy to understand and provides a reliable benchmark for more advanced techniques.
8 Applications
The trapezoidal rule appears in many computational settings where integrals must be approximated from discrete data. Its simplicity makes it a standard tool across scientific and engineering work.
8.1 Approximating definite integrals
The most direct application is the approximation of definite integrals in calculus. When an antiderivative is unavailable or cumbersome to compute, the trapezoidal rule gives a quick numerical estimate.
It is also useful when the function is known only through sampled values. In that case, the method can estimate area, accumulated quantity, or average value from the data alone.
8.2 Physics and engineering problems
In physics and engineering, the rule is used to approximate quantities such as work, displacement from velocity data, charge from current measurements, and total energy from sampled signals. It is especially convenient when measurements are recorded at evenly spaced times or locations.
The rule also appears in simulation and data analysis, where integrals are needed as part of larger computational pipelines. Its low overhead makes it suitable for repeated use in iterative calculations.
8.3 Numerical solution of differential equations
The trapezoidal rule is closely related to numerical methods for differential equations, particularly those that convert an integral form of the problem into a discrete update. In this context, it can serve as a building block for time-stepping schemes.
Because it uses an average of endpoint information, the rule often produces more balanced approximations than forward-only methods. This makes it useful in contexts where improved accuracy and stability are both important.
9 Variants and extensions
Several refinements of the trapezoidal rule adapt it to different kinds of integrands, data sources, and geometries. These extensions preserve the same basic idea while modifying the node selection or partitioning strategy.
9.1 Adaptive trapezoidal rule
The adaptive trapezoidal rule adjusts the subinterval widths according to the local behavior of the function. Regions with rapid variation are divided more finely, while smoother regions use larger steps.
This approach can improve efficiency by concentrating work where it is most needed. It is often paired with an error estimate so that refinement continues until a target accuracy is achieved.
9.2 Open trapezoidal-type formulas
Open formulas are variants that avoid evaluating the function at the endpoints of the interval. They may be useful when endpoint values are unavailable, undefined, or inconvenient to compute.
Although they differ in node placement, open formulas preserve the same general philosophy of approximating an integral by a weighted sum of sampled values. They are part of a broader family of quadrature rules related to the trapezoidal method.
9.3 Trapezoidal rule in multiple dimensions
In higher dimensions, the trapezoidal idea can be extended by applying one-dimensional trapezoidal approximations successively along each axis. The result is a multidimensional quadrature rule for rectangular domains.
Such tensor-product versions are common in numerical analysis, though the number of sample points can grow quickly with dimension. Even so, the basic principle remains the same: approximate a curved region by a structured collection of simple geometric pieces.