ArticleslgStudy

science

Trapezoidal rule

Trapezoidal rule is a science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Trapezoidal rule rather than just read about it. In short: In calculus, the trapezoidal rule (informally trapezoid rule; or in British English trapezium rule) is a technique for numerical integration, i.e. approximating the definite integral: ∫abf(x)dx. The trapezoidal rule works by approximating the region under the graph of the function f(x) as a trapezoid and calculating its area.

Trapezoidal rule — main illustration
Trapezoidal rule — illustration

Key takeaways

  • Trapezoidal rule belongs to science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Trapezoidal rule to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Trapezoidal rule from memory before moving on to harder problems.

Reference excerpt

In calculus, the trapezoidal rule (informally trapezoid rule; or in British English trapezium rule) is a technique for numerical integration, i.e. approximating the definite integral: ∫abf(x)dx.

The trapezoidal rule works by approximating the region under the graph of the function f(x) as a trapezoid and calculating its area. This is easily calculated by noting that the area of the region is made up of a rectangle with width (b−a) and height f(a), and a triangle of width (b−a) and height f(b)−f(a). Therefore, ∫abf(x)dx≈(b−a)⋅f(a)⏟Area of rectangle+12(b−a)⋅[f(b)−f(a)]⏟Area of triangle=(b−a)⋅(f(a)+12f(b)−12f(a))=(b−a)⋅(12f(a)+12f(b))=12(b−a)[f(a)+f(b)]. The rule can also be derived by replacing the integrand with the equation of the line joining points (a,f(a)) and (b,f(b)), which using the two point form of the equation of a line, is y=(x−a)f(b)−f(a)b−a+f(a). Therefore, ∫abf(x)dx≈∫ab(x−a)f(b)−f(a)b−a+f(a)dx=[12(x−a)2f(b)−f(a)b−a+xf(a)]x=ax=b=[12(b−a)2f(b)−f(a)b−a+bf(a)]−af(a)=12(b−a)[f(b)−f(a)]+(b−a)f(a)=12(b−a)[f(a)+f(b)], as before.

The integral can be even better approximated by partitioning the integration interval, applying the trapezoidal rule to each subinterval and summing the results. In practice, this "chained" (or "composite") trapezoidal rule is usually what is meant by "integrating with the trapezoidal rule". Let {xk} be a partition of [a,b] such that a=x0<x1<⋯<xN−1<xN=b, and Δxk be the length of the k-th subinterval (that is, Δxk=xk−xk−1), then ∫abf(x)dx≈∑k=1Nf(xk−1)+f(xk)2Δxk. The trapezoidal rule may be viewed as the result obtained by averaging the left and right Riemann sums and is sometimes defined this way. The approximation becomes more accurate as the resolution of the partition increases (that is, for larger N, all Δxk decrease). When all the Δxk have the same value Δx, as is often the case, the formula can be simplified for calculation efficiency by factoring Δx out: ∫abf(x)dx≈Δx(f(x0)+f(xN)2+∑k=1N−1f(xk)). As discussed below, it is also possible to place error bounds on the accuracy of the value of a definite integral estimated using a trapezoidal rule.

History Evidence discovered in Babylonian cuneiform tablets circa 200 BCE predicting the motion of Jupiter along the ecliptic suggests that the trapezoid rule was in use for astronomical prediction long before calculus itself was invented.

Numerical implementation

Non-uniform grid When the grid spacing is non-uniform, one can use the formula ∫abf(x)dx≈∑k=1Nf(xk−1)+f(xk)2Δxk, where Δxk=xk−xk−1, or more a computationally efficient formula ∫abf(x)dx≈12(f(x0)Δ+1x0+f(xN)Δ−1xN+∑k=1N−1f(xk)Δ±1xk), where Δ+1x0=x1−x0, Δ−1xN=xN−xN−1, Δ±1xk=xk+1−xk−1 are the corresponding forward, backward, and central differences.

Uniform grid For a domain partitioned by N+1 equally spaced points, considerable simplification may occur. Let Δx=b−aN and xk=a+kΔx for k=0,1,…,N. The approximation to the integral becomes ∫abf(x)dx≈Δx2∑k=1N[f(xk−1)+f(xk)]=Δx(12f(x0)+12f(xN)+∑k=1N−1f(xk)). Sometimes this expression is written as Δx ∑)′k=0Nf(xk), where the symbol ⁠∑ ′⁠ indicates that the first and last terms are halved.

Error analysis

The error of the composite trapezoidal rule is the difference between the value of the integral and the numerical result: E=∫abf(x)dx−b−aN[f(a)+f(b)2+∑k=1N−1f(a+kb−aN)] There exists a number ξ between a and b, such that E=−(b−a)312N2f″(ξ) It follows that if the integrand is concave up (and thus has a positive second derivative), then the error is negative and the trapezoidal rule overestimates the true value. This can also be seen from the geometric picture: the trapezoids include all of the area under the curve and extend over it. Similarly, a concave-down function yields an underestimate because area is unaccounted for under the curve, but none is counted above. If the interval of the integral being approximated includes an inflection point, the sign of the error is harder to identify. An asymptotic error estimate for N → ∞ is given by E=−(b−a)212N2[f′(b)−f′(a)]+O(N−3). Further terms in this error estimate are given by the Euler–Maclaurin summation formula. Several techniques can be used to analyze the error, including:

Fourier series Residue calculus Euler–Maclaurin summation formula Polynomial interpolation It is argued that the speed of convergence of the trapezoidal rule reflects and can be used as a definition of classes of smoothness of the functions.

Proof First suppose that h=b−aN and ak=a+(k−1)h. Let gk(t)=12t[f(ak)+f(ak+t)]−∫akak+tf(x)dx be the function such that |gk(h)| is the error of the trapezoidal rule on one of the intervals, [ak,ak+h]. Then dgkdt=12[f(ak)+f(ak+t)]+12t⋅f′(ak+t)−f(ak+t), and d2gkdt2=12t⋅f″(ak+t). Now suppose that |f″(x)|≤|f″(ξ)|, which holds if f is sufficiently smooth. It then follows that |f″(ak+t)|≤f″(ξ) which is equivalent to −f″(ξ)≤f″(ak+t)≤f″(ξ), or −f″(ξ)t2≤gk″(t)≤f″(ξ)t2. Since gk′(0)=0 and gk(0)=0, ∫0tgk″(x)dx=gk′(t) and ∫0tgk′(x)dx=gk(t). Using these results, we find −f″(ξ)t24≤gk′(t)≤f″(ξ)t24 and −f″(ξ)t312≤gk(t)≤f″(ξ)t312 Letting t=h we find −f″(ξ)h312≤gk(h)≤f″(ξ)h312. Summing all of the local error terms we find ∑k=1Ngk(h)=b−aN[f(a)+f(b)2+∑k=1N−1f(a+kb−aN)]−∫abf(x)dx. But we also have −∑k=1Nf″(ξ)h312≤∑k=1Ngk(h)≤∑k=1Nf″(ξ)h312 and ∑k=1Nf″(ξ)h312=f″(ξ)h3N12, so that −f″(ξ)h3N12≤b−aN[f(a)+f(b)2+∑k=1N−1f(a+kb−aN)]−∫abf(x)dx≤f″(ξ)h3N12. Therefore the total error is bounded by error=|∫abf(x)dx−b−aN[f(a)+f(b)2+∑k=1N−1f(a+kb−aN)]|≤f″(ξ)h3N12=f″(ξ)(b−a)312N2.

Periodic and peak functions The trapezoidal rule converges rapidly for periodic functions. This is an easy consequence of the Euler–Maclaurin summation formula, which says that if f is p times continuously differentiable with period T, then ∑k=0N−1f(kh)h=∫0Tf(x)dx+∑k=1⌊p/2⌋B2k(2k)!(f(2k−1)(T)−f(2k−1)(0))−(−1)php∫0TB~p(x/T)f(p)(x)dx, where h:=T/N, and B~p is the periodic extension of the p-th Bernoulli polynomial. Due to the periodicity, the derivatives at the endpoint cancel, and we see that the error is O(hp). A similar effect is available for peak-like functions, such as Gaussian, Exponentially modified Gaussian and other functions with derivatives at integration limits that can be neglected. The evaluation of the full integral of a Gaussian function by trapezoidal rule with 1% accuracy can be made using just 4 points. Simpson's rule requires 1.8 times more points to achieve the same accuracy.

… excerpt ends here. Continue reading the full article.

Illustrations

Trapezoidal rule: The function f(x) (in blue) is approximated by a linear function (in red).
The function f(x) (in blue) is approximated by a linear function (in red).
Trapezoidal rule: An animation that shows what the trapezoidal rule is and how the error in approximation decreases as the step size decreases
An animation that shows what the trapezoidal rule is and how the error in approximation decreases as the step size decreases
Trapezoidal rule: Illustration of "chained trapezoidal rule" used on an irregularly spaced partition of [a,b]
Illustration of "chained trapezoidal rule" used on an irregularly spaced partition of [a,b]
Trapezoidal rule: An animation showing how the trapezoidal rule approximation improves with more strips for an interval with a=2 and b=8. As the number of intervals N increases, so too does the accuracy of the result.
An animation showing how the trapezoidal rule approximation improves with more strips for an interval with a=2 and b=8. As the number of intervals N increases, so too does the accuracy of the result.

Worked examples

Example 1 — a first encounter with Trapezoidal rule

Start with the simplest possible case. Write down what Trapezoidal rule claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Trapezoidal rule before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Trapezoidal rule ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Trapezoidal rule

In research
Trapezoidal rule appears in science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Trapezoidal rule in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Trapezoidal rule is common in secondary-school and first-year university syllabi. It links to neighbouring topics Numerical integration, so understanding it makes those chapters shorter.
In everyday life
Look for Trapezoidal rule outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Trapezoidal rule” →

How to study Trapezoidal rule in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Trapezoidal rule means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Trapezoidal rule out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Trapezoidal rule in simple terms?

In calculus, the trapezoidal rule (informally trapezoid rule; or in British English trapezium rule) is a technique for numerical integration, i.e. approximating the definite integral: ∫abf(x)dx. The trapezoidal rule works by approximating the region under the graph of the function f(x) as a trapezo…

Why does Trapezoidal rule matter?

Because it connects several science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Trapezoidal rule?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Trapezoidal rule.

Tags

  • Numerical integration

Keep exploring