Skip to content

The trapezium rule: numerical integration and area estimates

The trapezium rule estimates a definite integral by replacing a curve with straight line segments. The area below each segment is a trapezium, so the method is a form of numerical integration.

For nn equal strips of width

h=ban,h=\frac{b-a}{n},

the rule is

abf(x)dxh2[y0+2(y1+y2++yn1)+yn],\boxed{ \int_a^b f(x)\,dx \approx \frac{h}{2}\left[y_0+2(y_1+y_2+\cdots+y_{n-1})+y_n\right] },

where yr=f(a+rh)y_r=f(a+rh). The first and last ordinates occur once; every interior ordinate occurs twice.

You should be able to:

  • evaluate a function accurately with a calculator;
  • interpret a definite integral as signed area;
  • find the area of a trapezium;
  • distinguish the number of strips from the number of ordinates.

If exact integration is available, it is usually preferable. The trapezium rule is needed when an antiderivative is unavailable, awkward, or when the function is known only through measured data.

For one strip from xrx_r to xr+1x_{r+1}, let the parallel vertical sides have lengths yry_r and yr+1y_{r+1} and let the horizontal width be hh. Its area is

Ar=12(yr+yr+1)h.A_r=\frac12(y_r+y_{r+1})h.

For four strips, adding the four trapezia gives

Ah2[(y0+y1)+(y1+y2)+(y2+y3)+(y3+y4)]=h2[y0+2y1+2y2+2y3+y4].\begin{aligned} A&\approx\frac h2\big[(y_0+y_1)+(y_1+y_2)+(y_2+y_3)+(y_3+y_4)\big]\\ &=\frac h2\big[y_0+2y_1+2y_2+2y_3+y_4\big]. \end{aligned}

This explains the coefficient pattern

1,2,2,,2,1.\boxed{1,2,2,\ldots,2,1}.

It is safer to understand this pattern than to memorise an unexplained formula.

  1. Calculate the strip width h=(ba)/nh=(b-a)/n.
  2. List all n+1n+1 values of xx, including both endpoints.
  3. Calculate the ordinates yr=f(xr)y_r=f(x_r), keeping extra digits.
  4. Apply the coefficient pattern 1,2,2,,2,11,2,2,\ldots,2,1.
  5. Multiply the completed bracket by h/2h/2.
  6. Round only the final answer, as instructed.

Worked example 1: a function over four strips

Section titled “Worked example 1: a function over four strips”

Use four strips to estimate

02x2dx.\int_0^2 x^2\,dx.

There are n=4n=4 strips, so

h=204=0.5.h=\frac{2-0}{4}=0.5.

Four strips require five ordinates:

rr0011223344
xrx_r000.50.5111.51.522
yr=xr2y_r=x_r^2000.250.25112.252.2544

Substitute carefully:

02x2dx0.52[0+2(0.25+1+2.25)+4]=0.25[0+7+4]=2.75.\begin{aligned} \int_0^2x^2\,dx &\approx\frac{0.5}{2}\left[0+2(0.25+1+2.25)+4\right]\\ &=0.25[0+7+4]\\ &=\boxed{2.75}. \end{aligned}

The exact value is 8/3=2.6668/3=2.666\ldots, so this estimate is slightly too large. The reason is geometric, not accidental: y=x2y=x^2 curves upwards, and the joining chords lie above the curve.

Use three strips to estimate

14xdx.\int_1^4\sqrt{x}\,dx.

Give the answer to three decimal places.

Answer

Here h=(41)/3=1h=(4-1)/3=1, and the ordinates are

1,2,3,2.1,\quad \sqrt2,\quad \sqrt3,\quad 2.

Therefore

14xdx12[1+2(2+3)+2]=4.646=4.646.\begin{aligned} \int_1^4\sqrt{x}\,dx &\approx\frac12\left[1+2(\sqrt2+\sqrt3)+2\right]\\ &=4.646\ldots\\ &=\boxed{4.646}. \end{aligned}

Three strips require four ordinates.

Numerical integration is particularly valuable for experimental data because there may be no formula to integrate. First check that the xx values are equally spaced.

The table gives values of y=1/xy=1/x. Use the trapezium rule with four strips to estimate the area from x=1x=1 to x=2x=2.

xx1.001.001.251.251.501.501.751.752.002.00
yy1.00001.00000.80000.80000.66670.66670.57140.57140.50000.5000

The common spacing is h=0.25h=0.25. Hence

121xdx0.252[1.0000+2(0.8000+0.6667+0.5714)+0.5000]=0.125(5.5762)=0.697025.\begin{aligned} \int_1^2\frac1x\,dx &\approx\frac{0.25}{2} \left[1.0000+2(0.8000+0.6667+0.5714)+0.5000\right]\\ &=0.125(5.5762)\\ &=\boxed{0.697025}. \end{aligned}

Using the rounded table values limits the precision of the estimate. It would be misleading to claim many reliable decimal places.

The ordinates 33, 55, pp, and 44 are equally spaced by 22 units. The trapezium rule gives an estimated area of 2525. Find pp.

There are four ordinates, so there are three strips. Apply the coefficients 1,2,2,11,2,2,1:

25=22[3+2(5)+2p+4].25=\frac22[3+2(5)+2p+4].

Thus

25=17+2p,25=17+2p,

so

p=4.\boxed{p=4}.

Do not interpret four ordinates as four strips. The intervals between consecutive ordinates are the strips.

The compact formula assumes one common width hh. If the xx values are not equally spaced, calculate each trapezium separately:

abf(x)dxr=0n1xr+1xr2(yr+yr+1).\boxed{ \int_a^b f(x)\,dx \approx \sum_{r=0}^{n-1}\frac{x_{r+1}-x_r}{2}(y_r+y_{r+1}) }.

Estimate the integral represented by this table.

xx00113344
yy22554488

The widths are 11, 22, and 11, so a single value of hh cannot be used:

I12(2+5)+22(5+4)+12(4+8)=3.5+9+6=18.5.\begin{aligned} I&\approx\frac12(2+5) +\frac22(5+4) +\frac12(4+8)\\ &=3.5+9+6\\ &=\boxed{18.5}. \end{aligned}

The rule replaces each piece of curve by a chord joining its endpoints.

  • If f(x)>0f''(x)>0, the graph is convex, or curves upwards. Chords lie above the graph, so the rule gives an overestimate.
  • If f(x)<0f''(x)<0, the graph is concave, or curves downwards. Chords lie below the graph, so the rule gives an underestimate.
  • If ff is linear, the chords are the graph itself and the rule is exact.
  • If concavity changes within the interval, errors from different strips can have different signs. A single global conclusion may not be possible from ff'' alone.

This discussion concerns the signed integral. If the graph crosses the xx axis, negative ordinates produce negative trapezium contributions. To estimate geometric area, split the interval at each crossing and make each contribution positive.

Worked example 5: predict the direction of error

Section titled “Worked example 5: predict the direction of error”

Without finding the exact integral, decide whether the trapezium rule overestimates or underestimates

01exdx.\int_0^1 e^{-x}\,dx.

For f(x)=exf(x)=e^{-x},

f(x)=ex>0.f''(x)=e^{-x}>0.

The graph curves upwards throughout [0,1][0,1], so every chord lies above the curve. The trapezium rule gives an

overestimate.\boxed{\text{overestimate}.}

Notice that a decreasing function can still curve upwards. Increasing or decreasing behaviour does not determine the direction of trapezium rule error.

State whether the trapezium rule gives an overestimate, an underestimate, or an exact value in each case.

  1. 02(3x+1)dx\displaystyle \int_0^2(3x+1)\,dx
  2. 0π/2sinxdx\displaystyle \int_0^{\pi/2}\sin x\,dx
  3. 13lnxdx\displaystyle \int_1^3\ln x\,dx
Answers
  1. Exact. The graph is a straight line, so every trapezium matches the region exactly.
  2. Underestimate. On this interval, f(x)=sinx0f''(x)=-\sin x\leq0, so the graph curves downwards.
  3. Underestimate. Since f(x)=1/x2<0f''(x)=-1/x^2<0, the graph curves downwards.

For a smooth curve, using more equal strips makes each chord follow the curve more closely. Since

h=ban,h=\frac{b-a}{n},

increasing nn decreases hh. The trapezium rule converges to the exact integral as hh tends to zero under the usual smoothness conditions.

For sufficiently smooth ff, the total error is proportional to h2h^2 in leading order. Consequently, halving hh usually reduces the error by a factor of about 44. This is a guide, not a justification for inventing precision when the original data are rounded or noisy.

Estimate 02x2dx\int_0^2x^2\,dx with two strips and four strips.

With two strips, h=1h=1:

T2=12[0+2(1)+4]=3.T_2=\frac12[0+2(1)+4]=3.

With four strips, Example 1 gave

T4=2.75.T_4=2.75.

The exact value is 8/38/3, so the absolute errors are

383=13\left|3-\frac83\right|=\frac13

and

2.7583=112.\left|2.75-\frac83\right|=\frac1{12}.

Halving the width has divided the error by exactly 44 in this quadratic example.

nn strips require n+1n+1 ordinates. The endpoints are both included.

Only interior ordinates have coefficient 22. The endpoint coefficients are 11.

The bracket is a weighted sum of heights, not an area. Multiplication by h/2h/2 supplies the horizontal scale.

Store full calculator values and round once at the end. If a question supplies a rounded table, use those given values.

Assuming more strips always means a better real world answer

Section titled “Assuming more strips always means a better real world answer”

More strips reduce the discretisation error for a smooth known function. They cannot remove measurement error or restore information absent from sparse data.

A definite integral is signed. Below the xx axis, the ordinate and the trapezium contribution are negative.

  1. Use four strips to estimate 0111+x2dx\displaystyle \int_0^1\frac{1}{1+x^2}\,dx. Give your answer to four decimal places.
  2. Explain, without evaluating the exact integral, whether your answer to question 1 is necessarily an overestimate or underestimate over the whole interval.
  3. Five ordinates are used between x=2x=2 and x=5x=5. If they are equally spaced, find nn and hh.
Answers
  1. Here h=0.25h=0.25 and
x00.250.50.75111+x210.9411760.80.640.5\begin{array}{c|ccccc} x&0&0.25&0.5&0.75&1\\ \hline \dfrac1{1+x^2}&1&0.941176\ldots&0.8&0.64&0.5 \end{array}

so

T4=0.252[1+2(0.941176+0.8+0.64)+0.5]=0.782794=0.7828.\begin{aligned} T_4 &=\frac{0.25}{2}[1+2(0.941176\ldots+0.8+0.64)+0.5]\\ &=0.782794\ldots\\ &=\boxed{0.7828}. \end{aligned}
  1. For f(x)=(1+x2)1f(x)=(1+x^2)^{-1},
f(x)=6x22(1+x2)3.f''(x)=\frac{6x^2-2}{(1+x^2)^3}.

This changes sign at x=1/3x=1/\sqrt3, so the graph changes concavity within [0,1][0,1]. The simple concavity test does not determine one error direction for the whole interval.

  1. Five ordinates form four strips, so n=4n=4 and
h=524=0.75.h=\frac{5-2}{4}=\boxed{0.75}.