Fact-checked by Grok 2 weeks ago

Trapezoidal rule

The trapezoidal rule, also known as the trapezoid rule or trapezium rule, is a fundamental method in for approximating the definite of a over an by dividing the region into trapezoidal areas. Geometrically, it estimates the area under the curve by fitting straight lines between consecutive points on the function and summing the areas of the resulting trapezoids, providing an exact result for linear functions (polynomials of degree at most one). For a single subinterval from a to b, the basic formula is \int_a^b f(x) \, dx \approx \frac{b-a}{2} [f(a) + f(b)], which represents the area of the trapezoid formed by the points (a, f(a)), (a, 0), (b, 0), and (b, f(b)). In the composite version, the interval [a, b] is partitioned into n equal subintervals of width h = (b - a)/n, yielding the approximation \int_a^b f(x) \, dx \approx \frac{h}{2} \left[ f(a) + 2 \sum_{i=1}^{n-1} f(a + i h) + f(b) \right]. The method originates from the Newton-Cotes formulas, where the integrand is approximated by a first-degree , and it serves as an improvement over simple rectangular (Riemann) sums by averaging the left and right endpoint approximations. The error for the composite trapezoidal rule is E_T = -\frac{(b-a) h^2}{12} f''(\xi) for some \xi \in [a, b], assuming f'' is continuous, indicating second-order accuracy that improves with more subintervals. This error term highlights its suitability for smooth functions, though it may underperform for highly oscillatory or concave functions compared to higher-order methods like .

Fundamentals

Definition and Geometric Basis

The trapezoidal rule is a method that approximates the definite of a f(x) over an [a, b] by the area of a . Specifically, for a single , it estimates \int_a^b f(x) \, dx \approx \frac{b-a}{2} \left[ f(a) + f(b) \right]. This formula arises from treating the integrand values at the endpoints as the parallel sides (or bases) of a , with the length b - a serving as the (or between the parallel sides). Geometrically, the definite \int_a^b f(x) \, dx represents the exact area under the y = f(x) from x = a to x = b, assuming f(x) \geq 0 for simplicity. The trapezoidal rule approximates this area by inscribing a within the region bounded by the x-axis, the vertical lines at x = a and x = b, and the connecting the points (a, f(a)) and (b, f(b)). The two parallel sides of the trapezoid are the vertical lines at the endpoints (of lengths f(a) and f(b)), while the non-parallel sides are the segment on the x-axis of length b - a and the segment of length \sqrt{(b-a)^2 + (f(b) - f(a))^2}; however, the area computation simplifies to the average of the endpoint heights times the base width, yielding the formula above. This approach provides a to the , which is more accurate than a rectangular for smooth functions. For broader application, the trapezoidal rule extends to the composite version by dividing the interval [a, b] into multiple subintervals and summing the trapezoidal areas over each, improving accuracy without altering the underlying geometric principle.

Motivation and Prerequisites

methods, such as the trapezoidal rule, become indispensable when determining an exact of a is challenging or outright impossible, thereby requiring reliable approximations to evaluate definite integrals./05%3A_Integration/5.05%3A_Numerical_Integration) This necessity arises frequently in and sciences, where functions may lack elementary antiderivatives, yet precise area computations under curves are essential for modeling physical phenomena or solving engineering problems. To grasp the trapezoidal rule, one must first be acquainted with the fundamentals of Riemann sums and the definition of a definite integral as the limit of such sums, which partition the interval into subintervals and approximate areas with simple shapes like rectangles. Moreover, the method presupposes that the integrand f(x) is continuous on the closed interval [a, b], ensuring the existence of the integral and the validity of the approximations. The trapezoidal rule stands out due to its inherent simplicity and ease of implementation, requiring only function evaluations at interval endpoints to form basic geometric approximations. This makes it especially suitable for smooth functions, where it provides efficient and reasonably accurate estimates without demanding advanced computational tools. Unlike exact integration via antiderivatives, which may prove intractable, the rule offers a practical motivational bridge for numerical approximation, geometrically interpreting the area as a series of fitted trapezoids.

Historical Development

Early Origins

The earliest documented use of a method analogous to the trapezoidal rule appears in ancient Babylonian astronomy, where tablets from approximately 350 to 50 BCE describe calculations of Jupiter's position along the ecliptic by approximating the area under a graph of velocity versus time using trapezoidal figures. This approach effectively computed the planet's displacement as the integral of its velocity, demonstrating an intuitive grasp of geometric area summation for predictive purposes without algebraic notation. Such techniques highlight the trapezoidal approximation's role in early scientific computation, particularly for celestial tracking. In the classical era, precursors to the trapezoidal rule emerged through geometric methods for area estimation. (c. 287–212 BCE) applied the to approximate areas bounded by curves, such as parabolas and circles, by successively refining polygons that inscribed or circumscribed the region, providing a rigorous limit-based foundation for numerical . This iterative polygon approximation shares conceptual similarities with trapezoidal summation as a natural extension of basic area calculations using linear segments. In the , (1598–1647) advanced area approximations via his method of indivisibles, summing infinitely thin planar slices to compute areas under curves, which parallels trapezoidal integration when slices are treated as linear trapezoids. The trapezoidal rule gained prominence in the late 17th and 18th centuries amid the development of calculus, with Isaac Newton employing numerical summation techniques, including trapezoidal approximations, in his manuscript Of Quadrature by Ordinates around 1695 for evaluating definite integrals. By the early 18th century, these ideas were formalized in quadrature tables within calculus texts, where trapezoidal sums facilitated practical computations of integrals for astronomical orbits and surveying measurements. Roger Cotes further systematized the approach in his 1722 posthumous work Harmonia mensurarum, presenting the general Newton-Cotes formulas of which the trapezoidal rule is the linear (n=1) case, enabling efficient table-based approximations without contemporary error bounds. Early applications extended to astronomy for integrating planetary velocities and to land surveying for estimating irregular plot areas by chaining trapezoids, reflecting its utility in pre-digital scientific practice.

Modern Formulations

In the early , the trapezoidal rule gained formal recognition within the burgeoning discipline of , as evidenced in and G. N. Watson's seminal text A Course of Modern Analysis (first published in , with the fourth edition appearing in 1927), which systematically presented it alongside other methods for approximating definite integrals. This integration reflected the rule's evolution from geometric heuristics into a precise tool for , emphasizing its simplicity and utility for practical calculations. Following , the trapezoidal rule became a cornerstone of amid the rise of electronic computers, where its straightforward implementation suited early programming efforts, such as those for ballistic trajectory integrations on the . By the mid-1950s, it was firmly established as a standard technique in textbooks; for instance, F. B. Hildebrand's Introduction to (1956) detailed the composite form of the rule, highlighting its error characteristics and role in broader strategies. In contemporary formulations, the trapezoidal rule has been refined for enhanced efficiency, particularly in schemes that dynamically adjust subinterval sizes to meet requirements, as implemented in modern software libraries like SciPy's integrate.trapz and Romberg integration routines. A notable theoretical advancement is the exponentially convergent variant for analytic functions over periodic intervals or the real line, which achieves geometric convergence rates superior to methods, as analyzed in detail by Trefethen and Weideman (2014). These developments underscore the rule's enduring relevance in and scientific simulations as of the 2020s.

Mathematical Formulation

Uniform Grid Implementation

The uniform grid implementation of the trapezoidal rule approximates the definite \int_a^b f(x) \, dx by partitioning the interval [a, b] into n equal subintervals, each of width h = (b - a)/n. The grid points are defined as x_k = a + k h for k = 0, 1, \dots, n, forming an equally spaced mesh that enables straightforward of local approximations. The composite formula arises by applying the basic trapezoidal rule to each subinterval and summing the results, yielding \int_a^b f(x) \, dx \approx \frac{h}{2} \left( f(a) + 2 \sum_{k=1}^{n-1} f(a + k h) + f(b) \right). This expression weights the endpoint values f(a) and f(b) by $1/2 and the interior points by $1, scaled by the subinterval width h. To compute the approximation iteratively, evaluate f at the and accumulate the weighted sum as follows (in ):
function composite_trapezoidal(a, b, n, f):
    h = (b - a) / n
    total = f(a) + f(b)
    for k = 1 to n-1:
        total += 2 * f(a + k * h)
    return (h / 2) * total
This loop-based approach is simple and suitable for small n, requiring O(n) evaluations of f. For large n, a vectorized form enhances efficiency by leveraging array operations on the vector of function values \mathbf{y} = [f(x_0), f(x_1), \dots, f(x_n)], computed as \frac{h}{2} \left( y_0 + 2 \sum_{k=1}^{n-1} y_k + y_n \right) = h \left( \frac{y_0 + y_n}{2} + \sum_{k=1}^{n-1} y_k \right). This avoids explicit loops, allowing optimized library functions (e.g., in NumPy or MATLAB) to perform the summation in a single pass, which is particularly beneficial for high-dimensional or parallel computations.

Non-Uniform Grid Implementation

The non-uniform grid implementation of the trapezoidal rule adapts the composite formulation to handle partitions of the [a, b] where subinterval widths differ. The is divided into n subintervals defined by strictly increasing points x_0 = a < x_1 < \cdots < x_n = b, with each subinterval width given by h_i = x_i - x_{i-1} for i = 1, \dots, n. This setup accommodates irregular spacing, contrasting with the uniform grid case where all h_i are equal. The approximation to \int_a^b f(x) \, dx is obtained by applying the single trapezoid rule to each subinterval and summing the results: \sum_{i=1}^n \frac{h_i}{2} \left( f(x_{i-1}) + f(x_i) \right). $$/7:_Integration/7.06:_Integrating_Functions_Given_as_Discrete_Data_Points) This generalized composite rule is employed when the function's behavior varies significantly across the domain, such as regions of rapid change requiring finer resolution, or when integrating discrete data from non-uniform sampling, like [sensor](/page/Sensor) measurements or observational datasets. By allowing variable $h_i$, it supports adaptive strategies that allocate more points where accuracy is critical, enhancing efficiency over fixed uniform grids.[](https://www.researchgate.net/publication/317339672_Numerical_Integration_Schemes_for_Unequal_Data_Spacing) Computationally, the method is straightforward and implemented via a simple loop that computes each $h_i$, evaluates the function at the endpoints if needed, and accumulates the contributions without relying on equal spacing. In programming environments, this involves arrays for the $x_i$ and $f(x_i)$ values, making it versatile for one-dimensional [integration](/page/Integration) in scientific [computing](/page/Computing) libraries. The approach scales linearly with n and avoids [interpolation](/page/Interpolation) overhead for given irregular points./7:_Integration/7.02:_Trapezoidal_Rule_of_Integration) ## Error Analysis ### Derivation of the Error Bound The derivation of the error bound for the trapezoidal rule begins with the single-interval case, assuming the function $f$ is twice continuously differentiable on the closed [interval](/page/Interval) $[a, b]$, denoted $f \in C^2[a, b]$. Let $h = b - a$. The trapezoidal rule approximates $\int_a^b f(x) \, dx \approx \frac{h}{2} \left( f(a) + f(b) \right)$. To find the error $E = \int_a^b f(x) \, dx - \frac{h}{2} \left( f(a) + f(b) \right)$, consider the linear interpolating [polynomial](/page/Polynomial) $P_1(x)$ that matches $f$ at $a$ and $b$: P_1(x) = f(a) + \frac{f(b) - f(a)}{h} (x - a). The interpolation error at any $x \in [a, b]$ is given by f(x) - P_1(x) = \frac{(x - a)(x - b)}{2} f''(\xi_x), for some $\xi_x \in (a, b)$, assuming $f''$ exists. Integrating both sides over $[a, b]$ yields the exact integral error: E = \int_a^b \left[ f(x) - P_1(x) \right] dx = \int_a^b \frac{(x - a)(x - b)}{2} f''(\xi_x) , dx. Since $f''$ is continuous on the compact interval $[a, b]$, it is bounded and uniformly continuous. By the mean value theorem for integrals, there exists some $\xi \in (a, b)$ such that \int_a^b f''(\xi_x) , dx = f''(\xi) \cdot h, leading to E = \frac{f''(\xi)}{2} \int_a^b (x - a)(x - b) , dx. To evaluate the integral, substitute $u = x - a$, so $dx = du$ and the limits change from 0 to $h$: \int_0^h u (u - h) , du = \int_0^h (u^2 - h u) , du = \left[ \frac{u^3}{3} - \frac{h u^2}{2} \right]_0^h = \frac{h^3}{3} - \frac{h \cdot h^2}{2} = \frac{h^3}{3} - \frac{h^3}{2} = -\frac{h^3}{6}. Thus, E = \frac{f''(\xi)}{2} \left( -\frac{h^3}{6} \right) = -\frac{h^3}{12} f''(\xi), for some $\xi \in (a, b)$. This establishes the error bound for a single interval, with $|E| \leq \frac{h^3}{12} \max_{x \in [a, b]} |f''(x)|$.[](http://homepage.math.uiowa.edu/~atkinson/ftp/ENA_Materials/Overheads/sec_5-2.pdf)[](https://mathweb.ucsd.edu/~ebender/20B/77_Trap.pdf) For the composite trapezoidal rule on a uniform grid, divide $[a, b]$ into $n$ subintervals, each of width $h = (b - a)/n$, with partition points $x_i = a + i h$ for $i = 0, 1, \dots, n$. The composite approximation is \int_a^b f(x) , dx \approx h \left( \frac{f(a) + f(b)}{2} + \sum_{i=1}^{n-1} f(x_i) \right). The total error is the sum of the errors over each subinterval $[x_{i-1}, x_i]$: E_{\text{total}} = \sum_{i=1}^n E_i = \sum_{i=1}^n \left( -\frac{h^3}{12} f''(\xi_i) \right) = -\frac{h^3}{12} \sum_{i=1}^n f''(\xi_i), for $\xi_i \in (x_{i-1}, x_i)$. Since $f''$ is continuous on $[a, b]$, by the intermediate value theorem for continuous functions, there exists some $\xi \in (a, b)$ such that \frac{1}{n} \sum_{i=1}^n f''(\xi_i) = f''(\xi). Thus, E_{\text{total}} = -\frac{h^3}{12} \cdot n \cdot f''(\xi) = -\frac{(b - a) h^2}{12} f''(\xi), demonstrating $O(h^2)$ convergence (or $O(1/n^2)$) as $n \to \infty$. The bound is $|E_{\text{total}}| \leq \frac{(b - a) h^2}{12} \max_{x \in [a, b]} |f''(x)|$.[](http://homepage.math.uiowa.edu/~atkinson/ftp/ENA_Materials/Overheads/sec_5-2.pdf)[](https://mathweb.ucsd.edu/~ebender/20B/77_Trap.pdf) ### Behavior for Specific Function Classes The trapezoidal rule exhibits particularly favorable behavior for periodic analytic functions, where it achieves [exponential](/page/Exponential) (geometric) convergence rates, significantly outperforming the standard O(1/n²) error estimate derived from the Euler-Maclaurin formula. This superior accuracy arises because the endpoint values match exactly due to periodicity, causing higher-order correction terms in the error expansion to vanish, effectively leveraging the function's [Fourier series](/page/Fourier_series) representation for rapid decay of [aliasing](/page/Aliasing) errors. For instance, when integrating functions like [cos](/page/Cos)(2πkx) over [0,1] for [integer](/page/Integer) k, the rule yields exact results, leading to overall [exponential](/page/Exponential) error reduction as the number of points increases.[](https://epubs.siam.org/doi/10.1137/130932132) In contrast, the rule performs worse for functions with sharp peaks or near singularities, where local variations in the second derivative amplify the [error](/page/Error) contributions. Gaussian peaks, often used to model such [behavior](/page/Behavior), illustrate this: although smooth globally, narrow Gaussians require denser sampling to control [errors](/page/Error), with approximately 0.62 points per standard deviation needed for 0.1% accuracy, highlighting deviations from the expected [quadratic](/page/Quadratic) [convergence](/page/Convergence) due to the peak's rapid [curvature](/page/Curvature) changes. Qualitative [error](/page/Error) comparisons show that halving the step size near the [peak](/page/Peak) reduces the [error](/page/Error) by less than a factor of four, underscoring the method's [sensitivity](/page/Sensitivity) to localized [sharpness](/page/Sharpness).[](http://www.multichrom.ru/Docs/2018ChILS-CompiIntRules.pdf) For rough functions lacking sufficient [smoothness](/page/Smoothness), such as those continuous but with discontinuous first [derivatives](/page/Hartshorn), the trapezoidal rule's [error](/page/Error) bound breaks down, resulting in only linear O(1/n) [convergence](/page/Convergence) instead of [quadratic](/page/Quadratic). A classic example is f(x) = |x| integrated over [-1,1], where the [kink](/page/Kink) at x=0 prevents the second [derivative](/page/Derivative) from being bounded, causing the [error](/page/Error) to scale linearly with the step size h rather than h². [Error](/page/Error) plots for this case reveal a steady but slower decay, with the absolute [error](/page/Error) halving upon doubling the number of subintervals, confirming the reduced [order](/page/Order) for non-smooth integrands.[](https://math.mit.edu/~stevenj/trap-iap-2011.pdf) ## Applications and Comparisons ### Practical Applications The trapezoidal rule finds widespread use in [engineering](/page/Engineering) and physics for approximating [integrals](/page/Integral) that arise in practical computations, such as estimating areas under curves derived from experimental [data](/page/Data) or physical models. In [signal processing](/page/Signal_processing), it is employed to integrate continuous-time signals approximated from discrete samples, providing a simple method for calculating [energy](/page/Energy) or [power](/page/Power) spectral densities in audio and vibration analysis.[](https://www.dsprelated.com/freebooks/pasp/Trapezoidal_Rule.html) For [trajectory](/page/Trajectory) calculations, the rule facilitates the determination of [displacement](/page/Displacement) from velocity-time [data](/page/Data) in [mechanics](/page/Mechanics), where it approximates the integral of velocity over time to yield [position](/page/Position) with sufficient accuracy for preliminary simulations.[](https://www.geeksforgeeks.org/maths/trapezoidal-rule/) Additionally, in solving ordinary differential equations (ODEs), the implicit trapezoidal method serves as a second-order accurate [integrator](/page/Integrator), balancing stability and efficiency for stiff systems in dynamic simulations like [chemical kinetics](/page/Chemical_kinetics) or electrical circuits.[](https://www.cs.cornell.edu/~bindel/class/cs3220-s12/notes/lec25.pdf) In computational software, the trapezoidal rule is implemented as a core function for [numerical integration](/page/Numerical_integration), enabling [rapid prototyping](/page/Rapid_prototyping) and analysis. MATLAB's `trapz` function computes the [integral](/page/Integral) using the composite trapezoidal rule over vectors or matrices, supporting both uniform and non-uniform spacing for multidimensional [data integration](/page/Data_integration) in [engineering](/page/Engineering) workflows.[](https://www.mathworks.com/help/matlab/ref/trapz.html) Similarly, Python's [NumPy](/page/NumPy) library provides `numpy.trapezoid` (with the deprecated alias `numpy.trapz` as of NumPy 2.0 in 2024), which integrates array-like data along specified axes using the trapezoidal approximation, making it a standard tool for scientific computing in data-driven physics applications.[](https://numpy.org/doc/stable/reference/generated/numpy.trapezoid.html) Adaptive variants of the trapezoidal rule enhance its utility in [quadrature](/page/Quadrature) libraries by incorporating error estimation and mesh refinement. In [SciPy](/page/SciPy), the `romberg` function leverages repeated trapezoidal integrations with [Richardson extrapolation](/page/Richardson_extrapolation) to achieve higher-order accuracy adaptively, suitable for functions with varying smoothness in optimization and modeling tasks.[](https://docs.scipy.org/doc/scipy/tutorial/integrate.html) The library's `trapezoid` function further supports composite applications with automatic handling of subintervals for improved precision. In modern contexts, the non-uniform trapezoidal rule is particularly valuable for [data analysis](/page/Data_analysis) from sensors, where sampling intervals are irregular due to event-driven acquisition in [IoT](/page/IOT) devices or [environmental monitoring](/page/Environmental_monitoring). This extension approximates integrals over unevenly spaced points, enabling accurate computation of accumulated quantities like total exposure or flow rates from real-world sensor streams without [interpolation](/page/Interpolation) artifacts.[](https://www.researchgate.net/publication/317339672_Numerical_Integration_Schemes_for_Unequal_Data_Spacing) ### Alternatives and Limitations While the trapezoidal rule provides a straightforward [approximation](/page/Approximation) for [numerical integration](/page/Numerical_integration), its second-order accuracy, characterized by an error term of O(h²) where h is the step size, limits its suitability for scenarios demanding high [precision](/page/Precision), as the [convergence](/page/Convergence) [rate](/page/Rate) slows significantly with increasing n compared to higher-order methods.[](https://math.dartmouth.edu/~m3cod/klbookLectures/406unit/trap.pdf) This order of [convergence](/page/Convergence) arises from the [linear interpolation](/page/Linear_interpolation) underlying the rule, which inadequately captures higher-order [curvature](/page/Curvature) in the integrand.[](https://www-users.cse.umn.edu/classes/Spring-2024/csci5302/Notes/Slides3/chap08.pdf) The method also exhibits poor performance for oscillatory functions or those with singularities in the interval of integration, where the error bound can degrade substantially due to rapid variations or non-smooth behavior not well-approximated by piecewise linear segments.[](https://www.colorado.edu/amath/sites/default/files/attached-files/2019_f_improving_trap_rule_sirev_submitted.pdf) Prominent alternatives include [Simpson's rule](/page/Simpson's_rule), which fits parabolic arcs to the data and achieves fourth-order accuracy O(h⁴), enabling faster convergence and better handling of smooth functions at the cost of requiring an even number of subintervals. [Gaussian quadrature](/page/Gaussian_quadrature) stands out for its exactness on polynomials of degree up to 2n-1 using only n evaluation points, offering superior efficiency for polynomial-like integrands by optimally placing nodes and weights, though it demands precomputed abscissas and is less flexible for arbitrary intervals without transformation.[](https://www.gcsu.edu/sites/files/page-assets/node-808/attachments/rothstein.pdf) Romberg integration builds directly on the trapezoidal rule by applying [Richardson extrapolation](/page/Richardson_extrapolation) to successive refinements, yielding higher-order estimates (up to exponential convergence for analytic functions) without additional function evaluations beyond the base method.[](https://www.math.ttu.edu/~vhowle/Courses/2010Spring_Math5335/quadNotes2.pdf) The trapezoidal rule remains preferable for rapid preliminary estimates, problems emphasizing endpoint function values, or as a foundational component in extrapolated schemes like Romberg, particularly when simplicity and minimal setup outweigh precision needs.[](https://www.johndcook.com/blog/2020/02/18/trapezoid-romberg/) In terms of trade-offs, the trapezoidal rule's computational cost is low, involving O(n) evaluations and simple arithmetic, but its lower order necessitates more points for comparable accuracy to alternatives like Gaussian quadrature, which, despite requiring fewer evaluations for high precision on smooth functions, involves more complex node selection and is computationally heavier per step.[](https://relate.cs.illinois.edu/course/cs450-s17/file-version/108b563f0496870001ffa4a77b504ff4d6ef57d1/lecture-notes/lec19.pdf) Simpson's rule strikes a balance, doubling the order over trapezoidal with similar ease of implementation but still lagging behind Gaussian for non-polynomial integrands.[](http://showard.sdsmt.edu/Math373/_AppliedNumMethodsText_SMH/09_Numerical_Integration/009_Numerical_Integration.pdf) ## Illustrative Examples ### Basic Numerical Example To illustrate the basic application of the trapezoidal rule, consider approximating the definite [integral](/page/Integral) $\int_0^1 e^x \, dx$. The exact value of this [integral](/page/Integral), obtained via the [fundamental theorem of calculus](/page/Fundamental_theorem_of_calculus), is $e - 1 \approx 1.71828$. For a single-interval implementation on the uniform grid with step size $h = b - a = 1$, the trapezoidal rule approximates the [integral](/page/Integral) as $\frac{h}{2} [f(a) + f(b)]$, where $f(x) = e^x$, $a = 0$, and $b = 1$./7%3A_Integration/7.02%3A_Trapezoidal_Rule_of_Integration) Substituting the values step by step: $f(0) = e^0 = 1$, $f(1) = e^1 \approx 2.71828$, so the approximation is $\frac{1}{2} (1 + 2.71828) = \frac{1 + e}{2} \approx 1.85914$./7%3A_Integration/7.02%3A_Trapezoidal_Rule_of_Integration) The absolute error for this approximation is the difference between the estimated and exact values: $1.85914 - 1.71828 \approx 0.14086$. This positive error indicates an overestimate, consistent with the rule's behavior for [convex](/page/Convex) functions like $e^x$. Geometrically, the trapezoidal rule estimates the area under the [curve](/page/Curve) $y = e^x$ from $x = 0$ to $x = 1$ by the area of a trapezoid with parallel sides of lengths $f(0) = 1$ and $f(1) = e \approx 2.71828$, and height $h = 1$. The straight-line segment connecting the endpoints $(0, 1)$ and $(1, e)$ lies above the concave-up [curve](/page/Curve), enclosing a region that includes the [integral](/page/Integral) area plus a small segment between the [chord](/page/Chord) and the [graph](/page/Graph)./7%3A_Integration/7.02%3A_Trapezoidal_Rule_of_Integration) ### Composite Rule Example To illustrate the application of the composite trapezoidal rule, consider the integral $\int_0^1 e^x \, dx$, whose exact value is $e - 1 \approx 1.71828$./7:_Integration/7.02:_Trapezoidal_Rule_of_Integration) Divide the interval $[0, 1]$ into $n=4$ equal subintervals, yielding step size $h = 1/4 = 0.25$. The grid points are $x_k = kh$ for $k = 0, 1, 2, 3, 4$, and the function values $f(x_k) = e^{x_k}$ are computed as follows. The following table lists the points, function values, and multipliers used in the weighted sum (1 for the endpoints, 2 for interior points): | $k$ | $x_k$ | $f(x_k) \approx$ | Multiplier | |-----|-------|------------------|------------| | 0 | 0.00 | 1.00000 | 1 | | 1 | 0.25 | 1.28403 | 2 | | 2 | 0.50 | 1.64872 | 2 | | 3 | 0.75 | 2.11700 | 2 | | 4 | 1.00 | 2.71828 | 1 | The composite trapezoidal approximation is given by \frac{h}{2} \left[ f(x_0) + 2 \sum_{k=1}^{3} f(x_k) + f(x_4) \right] = 0.125 \times (1 + 2 \times 5.04975 + 2.71828) \approx 1.72722. The absolute error is $|1.72722 - 1.71828| \approx 0.00894$./7:_Integration/7.02:_Trapezoidal_Rule_of_Integration) To demonstrate convergence, apply the rule with $n=2$ subintervals ($h=0.5$), yielding points $x_k = 0, 0.5, 1$ and function values $f(0)=1$, $f(0.5) \approx 1.64872$, $f(1) \approx 2.71828$. The approximation is $\frac{0.5}{2} [1 + 2 \times 1.64872 + 2.71828] \approx 1.75393$, with absolute error $\approx 0.03565$. The error for $n=4$ is approximately one-fourth that for $n=2$, consistent with the $O(1/n^2)$ convergence rate of the method./7:_Integration/7.02:_Trapezoidal_Rule_of_Integration) This reduction aligns with the predicted behavior from the error bound analysis.

References

  1. [1]
    [PDF] Chapter 07.02 Trapezoidal Rule of Integration
    Feb 7, 2010 · The trapezoidal rule is based on the Newton-Cotes formula that if one approximates the integrand by an th n order polynomial, then the integral ...Missing: explanation | Show results with:explanation
  2. [2]
    [PDF] Numerical Integration
    Feb 8, 2009 · Geometrically, the trapezoidal rule is equivalent to approximating the area of the trapezoid under the straight line connecting the two ...Missing: explanation | Show results with:explanation
  3. [3]
    [PDF] Numerical Integration
    That is, the Trapezoidal rule gives the exact result for polynomials of degree up to or equal to one.Missing: explanation | Show results with:explanation
  4. [4]
    5.9 Numerical Integration
    An alternative to LEFT , LEFT ( n ) , RIGHT , RIGHT ( n ) , and MID MID ( n ) is called the Trapezoid Rule. Rather than using a rectangle to estimate the ( ...
  5. [5]
    5.6 Numerical integration - Active Calculus
    The Midpoint Rule is typically twice as accurate as the Trapezoid Rule, and the signs of the respective errors of these rules are opposites. Hence, by taking ...
  6. [6]
    Numerical Integration Trapezoidal Rule - LTCC Online
    The trapezoidal rule which geometrically calculates the area of the trapezoid with base on the x-axis and heights f(xi) and f(xi+1). The area of the trapezoid ...
  7. [7]
    Understanding the trapezoidal rule (article) - Khan Academy
    By using trapezoids (aka the "trapezoid rule") we can get more accurate approximations than by using rectangles (aka "Riemann sums").
  8. [8]
    [PDF] Trapezoid and Simpson's rules - A Document With An Image
    Both rules are examples of what we refer to as numerical methods. In the Trapezoid rule method, we start with rectangular area-elements and replace their ...
  9. [9]
    [PDF] Improving the accuracy of the trapezoidal rule
    Jul 10, 2019 · The trapezoidal rule uses function values at equi-spaced nodes. It is very accurate for integrals over periodic intervals, but is usually quite ...
  10. [10]
    1.11 Numerical Integration
    By now the reader will have come to appreciate that integration is generally quite a bit more difficult than differentiation.
  11. [11]
    Archimedes - Biography - MacTutor - University of St Andrews
    In mechanics Archimedes discovered fundamental theorems concerning the centre of gravity of plane figures and solids. His most famous theorem gives the weight ...<|separator|>
  12. [12]
    The Exponentially Convergent Trapezoidal Rule | SIAM Review
    The Exponentially Convergent Trapezoidal Rule. Authors: Lloyd N. Trefethen and J. A. C. WeidemanAuthors Info & Affiliations. https://doi.org/10.1137/130932132.
  13. [13]
    [PDF] Numerical integration - Georgia State University
    Composite trapezoidal rule. Let x0 = a,x1,...,xn = b be a uniform partition of [a,b] with h = b-a n . Then we obtain the composite Trapezoidal rule: Z b a f ...
  14. [14]
    [PDF] 4.4 Composite Numerical Integration
    Composite Trapezoidal rule​​ 2[𝑎𝑎,𝑏𝑏],ℎ = 𝑏𝑏−𝑎𝑎 𝑛𝑛 , and 𝑑𝑑𝑗𝑗 = 𝑎𝑎 + 𝑗𝑗ℎ for 𝑗𝑗 = 0,⋯,𝑛𝑛.Missing: uniform grid
  15. [15]
    [PDF] Numerical Applications to Differential Equations
    Composite Trapezoidal Rule Consider an interval [a, b], define a uniform grid xk = a + kh where k = 0,...,n and h = b−a n then. Z b a f (x) dx = n−1. X j=0.
  16. [16]
    Trapezoid Rule - Python Numerical Methods
    The Trapezoid Rule fits a trapezoid into each subinterval and sums the areas of the trapezoid to approximate the total integral.
  17. [17]
    [PDF] Instructions
    (b) Find the formula for the composite trapezoidal rule using uniform intervals of size h = b−a n where n + 1 is the number of quadrature points. i.e. the ...
  18. [18]
    The trapezoidal rule: vectorization and perormance — Stat 159/259
    Here we discuss in detail the performance profile of various solutions to the exercise from our Numpy introduction, the trapezoidal rule.
  19. [19]
    trapz - Trapezoidal numerical integration - MATLAB - MathWorks
    trapz performs the integration over x first, producing a column vector. Then, the integration over y reduces the column vector to a single scalar. trapz ...
  20. [20]
    (PDF) Numerical Integration Schemes for Unequal Data Spacing
    Aug 8, 2025 · This is the general formula of Trapezoidal rule for unequal spacing. 50 Md. Mamun-Ur-Rashid Khan et al.: Numerical Integration Schemes for ...
  21. [21]
    [PDF] TRAPEZOIDAL METHOD ERROR FORMULA Theorem Let f(x) have ...
    DERIVING THE ERROR FORMULA. There are two stages in deriving the error: (1) Obtain the error formula for the case of a single subinterval (n = 1); (2) Use this ...
  22. [22]
    [PDF] Section 7.7 Deriving the Trapezoidal Rule Error - UCSD Math
    The derivation of the Midpoint Rule error is similar to that for the Trapezoidal Rule, but each interval has to be broken into two pieces. 1. Using integration ...Missing: definition | Show results with:definition
  23. [23]
    [PDF] 1 Comparison of integration rules in the case of very narrow ...
    It was shown that for Gaussian peak Trapezoidal rule requires 0.62 points per standard deviation (2.5 points per peak width at baseline) to achieve ...
  24. [24]
    [PDF] Numerical integration and the redemption of the trapezoidal rule
    Jan 5, 2011 · Many numerical-analysis textbooks instead analyze the error of the trapezoidal rule via something called Bernoulli polynomials; this ...
  25. [25]
    Trapezoidal Rule | Physical Audio Signal Processing
    The trapezoidal rule gets its name from the fact that it approximates an integral by summing the areas of trapezoids. This can be seen by writing Eq. $ ...
  26. [26]
    Trapezoidal Rule - GeeksforGeeks
    Jul 23, 2025 · The Trapezoidal Rule is a fundamental method in numerical integration used to approximate the value of a definite integral of the form b∫a ...
  27. [27]
    [PDF] Ordinary differential equations - CS@Cornell
    So far, we have introduced three methods for solving ordinary differential equations: forward Euler, backward Euler, and the trapezoidal rule: yn+1 = yn + ...
  28. [28]
    Integration (scipy.integrate) — SciPy v1.16.2 Manual
    Romberg integration uses the trapezoid rule at step-sizes related by a power of two and then performs Richardson extrapolation on these estimates to approximate ...
  29. [29]
    [PDF] Chapter 8 -- Numerical Integration and Differentiation
    Thus, we expect midpoint rule to have degree 0, trapezoid rule degree 1, Simpson's rule degree 2, etc. From Taylor series expansion, error for midpoint rule.
  30. [30]
    [PDF] The Comparison of the Trapezoid Rule and the Gaussian Quadrature
    May 3, 2018 · Integration is the calculation of the area under the curve a function f(x). The integral of f produces a family of an- tiderivatives F(x)+c that ...<|control11|><|separator|>
  31. [31]
    [PDF] Notes on numerical integraton - TTU Math - Texas Tech University
    Gauss-Kronrod methods use variants of Gaussian quadrature rules that are constructed so that a subset of points re-used through a sequence of refinements.
  32. [32]
    Trapezoid rule and Romberg integration
    Feb 18, 2020 · This post will look at two numerical integration methods, the trapezoid rule and Romberg's algorithm, and memoization.
  33. [33]
    [PDF] Outline - RELATE
    Other Considerations with Composite Trapezoidal Rule. Composite Trapezoidal Rule: (uniform spacing, n panels). Th := h f0 + f1. 2. + f1 + f2. 2. + ··· + fn-1.
  34. [34]
    [PDF] 9 – Numerical Integration
    Therefore, compared to the Rectilinear Rule, the Trapezoidal Rule approximation improves more rapidly with decreasing step size, h. 9.3 - Simpson's Integration.