Pure 9.4 - Numerical integration and the trapezium rule

Pure 9.4 - Numerical integration and the trapezium rule

Estimate an integral using straight-topped strips when a formula or a table supplies the function values. You will organise the calculation, use a sketch to judge the error, and turn suitable estimates into bounds for the true area.

Area from trapezia

Can joining five points by straight lines give an area you can trust? On y=2x+1y=\sqrt{2x+1} from 00 to 11, five points create four trapezia. Their total area is close to the curved area, and the curve's shape tells us which way the error goes.

You already know

A trapezium with parallel sides pp, qq, separated by distance hh, has area h(p+q)/2h(p+q)/2. A definite integral gives signed area; for a non-negative function it is the area under the graph. The single-trapezium area formula is not in the formula booklet.

Joining adjacent ordinates, meaning vertical heights, makes one trapezium per strip. The interior heights belong to two neighbouring strips; the end heights belong to one each.

[DIAGRAM: asset_slug: p1_9_4_understand_and_use_numerical_integration_of_functions_including_the_trapezium_rule__diagram_01; asset_name: Four trapezia below a square-root curve; caption: Five ordinates give four equal-width trapezia; description: The exact curve y=sqrt(2x+1) on 0 to 1 is compared with four shaded chord-topped trapezia at x=0,0.25,0.5,0.75,1. Heights y0 to y4 and h=0.25 are labelled.]
Five ordinates give four equal-width trapezia

Adding h(y0+y1)/2h(y_0+y_1)/2, h(y1+y2)/2h(y_1+y_2)/2, and the remaining strip areas explains the weights in the composite rule.

Trapezium rule

For nn equal strips, h=(b−a)/nh=(b-a)/n, and yi=f(a+ih)y_i=f(a+ih):

∫abf(x) dx≈h2[y0+yn+2(y1+⋯+yn−1)]\int_a^b f(x)\,\mathrm{d}x\approx\frac h2\left[y_0+y_n+2(y_1+\cdots+y_{n-1})\right]

The nn strips need n+1n+1 ordinates.

In the formula booklet.

This compact formula assumes equal spacing. For unequal widths, add the individual trapezium areas using their own widths instead.

Worked example 1: counting strips correctly

Question. An interval from 22 to 55 uses three equal strips. Find hh and the required number of ordinates.

Plan. Divide the interval length by the number of strips, then include both endpoints.

h=5−23=1strip widthx=2,3,4,5four ordinates\begin{aligned} h&=\frac{5-2}{3}=1 && \text{strip width} \\ x&=2,3,4,5 && \text{four ordinates} \end{aligned}

Why this step? Three gaps have four boundary positions.

Answer. h=1h=1, with four ordinates.

Check. Three widths of 11 cover the full length 33.

Change only the number of strips from three to six; the interval stays fixed.

Worked example 2: doubling the strips

Question. Divide the interval from 22 to 55 into six equal strips. Find hh and the number of ordinates.

Plan. Repeat the interval-length calculation with the new divisor.

h=5−26=0.5six gapsn+1=7including both ends\begin{aligned} h&=\frac{5-2}{6}=0.5 && \text{six gaps} \\ n+1&=7 && \text{including both ends} \end{aligned}

Why this step? Halving the width doubles the number of strips, rather than the number of ordinates.

Answer. h=0.5h=0.5, with seven ordinates.

Check. The positions 2,2.5,3,3.5,4,4.5,52,2.5,3,3.5,4,4.5,5 give exactly six gaps.

Count gaps before substituting into the rule.

Watch out

Wrong: six ordinates mean h=(b−a)/6h=(b-a)/6. Right: six ordinates give five strips, so h=(b−a)/5h=(b-a)/5. This changes the multiplier for the whole estimate.

Keep the interval and double the number of strips once more.

Using a table of values

Check equal spacing before using the composite rule. Then place the two end values outside the doubled interior sum. You are estimating an integral, not taking the mean of the readings.

Worked example 3: a supplied table

Question. Estimate ∫13f(x) dx\int_1^3 f(x)\,\mathrm{d}x using all these values.

xx111.51.5222.52.533
f(x)f(x)3.03.02.62.62.22.22.12.12.42.4

Plan. Use h=0.5h=0.5 and double only the three interior values.

T=0.52[3.0+2.4+2(2.6+2.2+2.1)]=0.25(5.4+13.8)collect the bracket=4.8\begin{aligned} T&=\frac{0.5}{2}[3.0+2.4+2(2.6+2.2+2.1)] \\ &=0.25(5.4+13.8) && \text{collect the bracket} \\ &=4.8 \end{aligned}

Why this step? Every interior height is shared by two trapezia.

Answer. The integral is approximately 4.84.8, or an area of 4.84.8 square units for a positive curve.

Check. The average height is estimated as 4.8/2=2.44.8/2=2.4, between the smallest and largest readings.

Keep the spacing and change only the middle reading from 2.22.2 to 2.82.8. Its doubled weight makes the effect easy to predict.

Worked example 4: changing an interior reading

Question. Repeat the estimate with the same xx-values and readings 3.0,2.6,2.8,2.1,2.43.0,2.6,2.8,2.1,2.4, in that order.

Plan. Substitute the new interior value into the same weighted sum.

T=0.25[3.0+2.4+2(2.6+2.8+2.1)]=0.25(5.4+15.0)new interior sum=5.1\begin{aligned} T&=0.25[3.0+2.4+2(2.6+2.8+2.1)] \\ &=0.25(5.4+15.0) && \text{new interior sum} \\ &=5.1 \end{aligned}

Why this step? Changing an interior ordinate by 0.60.6 changes the estimate by h(0.6)=0.3h(0.6)=0.3.

Answer. The new estimate is 5.15.1.

Check. 5.1−4.8=0.35.1-4.8=0.3, agreeing with that predicted change.

There is a neat exactness hidden here: if the graph is a straight line, every chord is already part of the graph, so the trapezium rule is exact for any number of strips. For instance, the line y=2x+1y=2x+1 on [0,1][0,1] has area 22, whether you use one trapezium or a hundred.

Exam tip

Write a numerical value of hh in the substitution. A correct weight pattern with the wrong strip width changes every part of the answer.

Use the supplied rounded values as the data; do not replace them by a guessed underlying function.

From a function to an estimate

When a function replaces a supplied table, calculate the required heights first. Keep extra figures in memory; round the table for display rather than feeding those rounded numbers into later calculations.

Worked example 5: building the table

Question. Estimate ∫012x+1 dx\int_0^1\sqrt{2x+1}\,\mathrm{d}x using four equal strips.

Plan. Evaluate the function at 0,0.25,0.5,0.75,10,0.25,0.5,0.75,1, then apply the rule.

xx000.250.250.50.50.750.7511
2x+1\sqrt{2x+1}1.00001.00001.22471.22471.41421.41421.58111.58111.73211.7321

Using unrounded heights,

T=0.252[1+3+2(1.5+2+2.5)]=1.396530667…weighted sum\begin{aligned} T&=\frac{0.25}{2}[1+\sqrt3+2(\sqrt{1.5}+\sqrt2+\sqrt{2.5})] \\ &=1.396530667\ldots && \text{weighted sum} \end{aligned}

Why this step? The five function evaluations define four strips; the three middle heights are doubled.

Answer. The estimate is 1.3971.397 to three decimal places.

Check. Using the displayed four-decimal table gives 1.39651251.3965125, which rounds to the same answer.

Change only the constant inside the square root from 11 to 22. The nodes and weights stay the same.

Continue this lesson.

You’re previewing NovaLearn without an account. Create a free account to read the rest.

Create free account