Tutorials › Calculus II › Unequal-Width Trapezoidal Panels

Quadrature and Error Bounds · Tutorial 365 of 998

Unequal-Width Trapezoidal Panels

Build a trapezoidal estimate for unequal panel widths by using each panel’s own width and endpoint values.

Intermediate 9 min read

What You'll Learn

  • Define a partition with unequal panel widths and identify its nodes.
  • Compute each trapezoidal contribution using that panel’s width.
  • Derive the nonuniform formula by integrating linear interpolants.
  • Rewrite the sum as weights on the sampled function values.
  • Recognize when the equal-spacing composite formula is valid.
  • Check a nonuniform estimate against an exact integral when available.

Why Panel Widths Matter

When the points at which a function is sampled are not equally spaced, the interval is divided into panels of different widths. Each panel contributes its own trapezoid estimate, so its width must be used in that contribution. Using one common width for all panels can produce a substantially different answer.

This is a direct extension of the composite trapezoidal rule. The basic idea stays the same: on each panel, use the function values at the two endpoints to form a straight-line approximation, then add the resulting signed areas. The calculation changes because the widths can vary from one panel to the next.

Partitions and the Unequal-Width Formula

Let \(a=x_0<x_1<\cdots<x_n=b\) be a partition of the interval \([a,b]\). The width of panel \(i\) is \(h_i=x_i-x_{i-1}\), which is positive. Write \(f_i=f(x_i)\). If \(f\) is continuous on \([a,b]\), its definite integral exists, and the trapezoidal sum gives an approximation to that integral.

Definition: The trapezoidal approximation on a partition with possibly unequal widths is $$ T=\sum_{i=1}^{n}\frac{h_i}{2}\bigl(f(x_{i-1})+f(x_i)\bigr), \qquad h_i=x_i-x_{i-1}. $$ Each summand is the contribution from one panel. Its width is that panel’s width, not an average or a width chosen for the whole interval.

For a single panel, the two endpoint heights are \(f(x_{i-1})\) and \(f(x_i)\). The trapezoid’s signed area is its width times the average of those heights. “Signed” matters: if the function lies below the horizontal axis, the contribution is negative. The formula approximates the signed definite integral, rather than the total geometric area between the graph and the axis.

The formula does not require equally spaced nodes. It does require using the correct endpoints and width for every panel. If the widths happen to be equal, it reduces to the familiar equal-spacing composite rule.

Why the Formula Works

On each panel, replace \(f\) by the straight line through its endpoint values. Integrating that line gives exactly the trapezoid contribution. Adding those panel integrals explains the unequal-width formula.

1
Construct the endpoint line.
On panel \(i\), the line through \((x_{i-1},f(x_{i-1}))\) and \((x_i,f(x_i))\) is \(L_i(x)=f(x_{i-1})+\dfrac{f(x_i)-f(x_{i-1})}{h_i}(x-x_{i-1})\).
2
Integrate across the panel.
With \(u=x-x_{i-1}\), the limits become \(0\) and \(h_i\). Integrating the constant and linear terms gives \(\int_{x_{i-1}}^{x_i}L_i(x)\,dx=h_i f(x_{i-1})+\dfrac{h_i}{2}(f(x_i)-f(x_{i-1}))=\dfrac{h_i}{2}(f(x_{i-1})+f(x_i))\).
3
Add all panel contributions.
The panels cover \([a,b]\) without gaps or overlaps except at shared endpoints. Adding their line integrals produces the stated sum \(T\).

This derivation also makes the method’s approximation explicit. The sum is the exact integral of the piecewise-linear function formed by joining the sampled points. It approximates the integral of \(f\) because those straight segments may differ from the graph between sampled nodes.

Equivalent Weights on the Function Values

The panel formula can be regrouped by function values. The first and last values appear in only one panel. Each interior value appears in two adjacent panels, with the width of each of those panels contributing to its coefficient.

$$ T=\frac{h_1}{2}f(x_0) +\sum_{i=1}^{n-1}\frac{h_i+h_{i+1}}{2}f(x_i) +\frac{h_n}{2}f(x_n). $$

This form is useful for seeing why unequal spacing changes the weights. An interior node \(x_i\) receives half the width of the panel to its left and half the width of the panel to its right. Only when every width equals the same \(h\) do all interior weights become \(h\), with endpoint weights \(h/2\).

Worked Examples

Worked Example: A Quadratic on Two Unequal Panels

Approximate \(\int_0^1 x^2\,dx\) using nodes \(x_0=0\), \(x_1=0.2\), and \(x_2=1\). The widths are \(h_1=0.2-0=0.2\) and \(h_2=1-0.2=0.8\). The sampled values are \(f(0)=0\), \(f(0.2)=(0.2)^2=0.04\), and \(f(1)=1\).

The first panel contributes \(\dfrac{0.2}{2}(0+0.04)=0.1(0.04)=0.004\). The second contributes \(\dfrac{0.8}{2}(0.04+1)=0.4(1.04)=0.416\). Therefore, \(T=0.004+0.416=0.420\).

Check the arithmetic by the panel sum: the widths add to \(0.2+0.8=1\), and the two contributions use the endpoint values on their respective panels. For comparison, the exact integral is \([x^3/3]_0^1=1/3\), about \(0.333333\). Thus this estimate is above the exact value.

Worked Example: A Linear Function on Three Unequal Panels

Approximate \(\int_{-1}^{3}(2x+1)\,dx\) using nodes \(-1,0,2,3\). The widths are \(1,2,1\), respectively. The function values are \(f(-1)=-1\), \(f(0)=1\), \(f(2)=5\), and \(f(3)=7\).

The panel contributions are \(\dfrac{1}{2}(-1+1)=0\), \(\dfrac{2}{2}(1+5)=6\), and \(\dfrac{1}{2}(5+7)=6\). Their sum is \(T=0+6+6=12\).

Check against the exact integral: \(\int(2x+1)\,dx=x^2+x\), so \([x^2+x]_{-1}^{3}=(9+3)-(1-1)=12-0=12\). The trapezoidal estimate is exact here. On every panel, a linear function already agrees with the straight line joining the endpoint values.

Worked Example: A Rational Function on Two Unequal Panels

Approximate \(\int_0^2 \dfrac{1}{1+x}\,dx\) using nodes \(0,\frac12,2\). The widths are \(h_1=\frac12\) and \(h_2=\frac32\). The function values are \(f(0)=1\), \(f(\frac12)=\frac{2}{3}\), and \(f(2)=\frac{1}{3}\).

The first contribution is \(\dfrac{1/2}{2}(1+\frac23)=\dfrac14\cdot\frac53=\frac{5}{12}\). The second is \(\dfrac{3/2}{2}(\frac23+\frac13)=\dfrac34\cdot1=\frac34=\frac{9}{12}\). Hence \(T=\frac{5}{12}+\frac{9}{12}=\frac{14}{12}=\frac76\).

Check by adding the panel widths: \(\frac12+\frac32=2\), the full interval length. For comparison, the exact integral is \([\ln(1+x)]_0^2=\ln 3\), about \(1.098612\). The estimate \(\frac76\), about \(1.166667\), is an approximation, not an exact evaluation.

Relation to the Equal-Spacing Composite Rule

If \(n\) panels have one common width \(h=(b-a)/n\), the panel sum can be rearranged as follows:

$$ T=\frac{h}{2}\left[f(x_0)+2\sum_{i=1}^{n-1}f(x_i)+f(x_n)\right]. $$

This is the equal-spacing composite trapezoidal formula. Its single \(h\) is valid because every panel has the same width. For unequal panels, the correct formula retains \(h_i\) inside each summand; applying the equal-spacing expression to irregular nodes generally changes the estimate.

Key takeaway: For a nonuniform partition, calculate the width \(h_i=x_i-x_{i-1}\) for every panel and pair it with that panel’s two endpoint values. Do not substitute one common width unless the nodes are equally spaced.

Common Mistake: Assuming One Width Fits All

Return to the partition \(0,0.2,1\) for \(f(x)=x^2\). It has two panels, but their widths are \(0.2\) and \(0.8\), not a common width. A mistaken calculation might set \(h=(1-0)/2=0.5\) and use the equal-spacing formula with the actual middle value \(f(0.2)=0.04\):

$$ \frac{0.5}{2}\bigl[f(0)+2f(0.2)+f(1)\bigr] =0.25(0+0.08+1)=0.27. $$

The calculation is wrong because the equal-spacing formula assumes the middle node is \(0.5\), not \(0.2\). The correction is to use the actual panel widths: \(\frac{0.2}{2}(0+0.04)+\frac{0.8}{2}(0.04+1)=0.004+0.416=0.420\). The key check is whether each adjacent pair of nodes is separated by the same distance.

When This Formulation Is Useful

Unequal-width panels arise whenever a grid is chosen to place more sample points in some parts of an interval than others. The panel-by-panel sum works directly with those nodes: no rescaling to an artificial uniform grid is needed. It also makes the contribution of each interval visible, which helps catch arithmetic errors and makes it easier to inspect which widths and function values have the largest effect on the total.

The formula itself is exact for the integral of the piecewise-linear interpolant, but it does not guarantee any particular accuracy for the original function. Accuracy depends on how well the interpolant follows that function between nodes. The equal-spacing composite error bound uses a common panel width; it should not be applied by simply inserting a single width when the panels are unequal.

Check Your Understanding

Use the panel-by-panel formula and show the width and endpoint values used in each contribution.

  1. For nodes \(0,1,3\), write the trapezoidal approximation to \(\int_0^3 f(x)\,dx\) in terms of \(f(0)\), \(f(1)\), and \(f(3)\).
  2. What condition on the nodes allows the unequal-width sum to be rewritten using one common width \(h\)?
  3. Why does an interior node receive a weight involving both adjacent panel widths?
  4. For \(f(x)=x\) and nodes \(0,0.5,2\), compute the trapezoidal sum and check it against the exact integral.
  5. What assumption about the spacing makes the equal-spacing composite formula invalid on a nonuniform grid?