HelpContactFor teachers and institutes
>_StemPy Lab
Mock TestsClasses

>_StemPy Lab

Learn. Solve. Code the solutions. Test yourself.

Live examsFree mock exams, timed and rankedEveryone starts together, and your score and rank come the moment it ends.See the exams →
Live examsInternational live exams are comingTell us which exam you want first. Timed practice papers are open now.See what is coming →

Learn

  • Physics
  • Chemistry
  • Mathematics
  • Biology
  • Python Programming
  • Statistics & Data Science
  • Computer Science
  • Space Science and Astronomy
  • Earth and Environmental Science
  • Classes
  • Groups

Practice

  • Problems
  • Quizzes
  • Mock Tests
  • Prepare for an Exam
  • Question Sets
  • Exams
  • Certificates
  • Python Labs
  • AI Practice Generator
  • Student-Created Tests

Community

  • Discussions
  • Resources
  • Notes
  • Glossary
  • Blog

Account

  • Log in
© 2026 senLearn. All rights reserved.HelpFor SchoolsAboutContactPrivacy PolicyTerms of UseRefund Policy
Numerical Integration and Hyperbolic Substitutions
  1. 1The trapezium and mid-ordinate rules
  2. 2Simpson's rule and error estimates
  3. 3Integrals by hyperbolic substitution
  1. Mathematics
  2. /Numerical Integration and Hyperbolic Substitutions
  3. /The trapezium and mid-ordinate rules

Course 34.3·Lesson 1 of 3

The trapezium and mid-ordinate rules

When an integral has no formula, or the function is known only from a table, we estimate the area by strips. The trapezium rule joins neighbouring points by straight lines. The mid-ordinate rule uses rectangles whose heights are taken at the middle of each strip. For a curve that bends upwards, the trapezium rule is too big and the mid-ordinate rule too small. Halving the strip width cuts both errors to about a quarter.

about 30 min1 simulation2 practice questions
Lesson 1 of 3Show all lessonsHide
Numerical Integration and Hyperbolic Substitutions
  1. 1The trapezium and mid-ordinate rules
  2. 2Simpson's rule and error estimates
  3. 3Integrals by hyperbolic substitution

Try the code and the simulations beside the lesson.

What you will be able to do

  • use the trapezium and mid-ordinate rules, from a formula or a table;
  • decide from the shape of the curve whether an estimate is too big or too small;
  • bound the error and choose the number of strips for a given accuracy.

A table and no formula

A car's speed is read every 10 s10\ \text{s}10 s. How far did it travel? Distance is the area under the speed-time graph, but we have only the readings. Even with a formula, many integrals, such as ∫01e−x2 dx\int_0^1 e^{-x^2}\,dx∫01​e−x2dx, have no antiderivative in simple functions. We need a rule that uses only values of the function.

The trapezium rule

Split [a,b][a, b][a,b] into nnn strips of width h=b−anh = \dfrac{b - a}{n}h=nb−a​, with ordinates y0,y1,…,yny_0, y_1, \ldots, y_ny0​,y1​,…,yn​. Join the tops by straight lines. Each strip is a trapezium of area h2(yk−1+yk)\tfrac{h}{2}(y_{k - 1} + y_k)2h​(yk−1​+yk​). Adding them gives

Tn=h2[y0+yn\displaystyle T_n = \dfrac{h}{2}\big[y_0 + y_nTn​=2h​[y0​+yn​
+2(y1+⋯+yn−1)].\displaystyle \qquad + 2(y_1 + \cdots + y_{n - 1})\big].+2(y1​+⋯+yn−1​)].

The two end ordinates count once, and every inner ordinate twice. Some books call it the trapezoidal rule, and AP Calculus calls it a trapezoidal sum.

The mid-ordinate rule

Take each strip as a rectangle, with its height measured at the middle of the strip:

Mn=h[f(m1)+⋯+f(mn)],\displaystyle M_n = h\big[f(m_1) + \cdots + f(m_n)\big],Mn​=h[f(m1​)+⋯+f(mn​)],

where mkm_kmk​ is the midpoint of the kkkth strip. AP Calculus calls this a midpoint Riemann sum.

A worked example

Estimate ∫12dxx\int_1^2 \dfrac{dx}{x}∫12​xdx​ with 444 strips, so h=0.25h = 0.25h=0.25. The exact value is ln⁡2≈0.693147\ln 2 \approx 0.693147ln2≈0.693147.

  1. The ordinates. 111, 0.80.80.8, 0.66670.66670.6667, 0.57140.57140.5714, 0.50.50.5.
  2. Trapezium. T4=0.125[1+0.5+2(2.0381)]≈0.697024T_4 = 0.125\big[1 + 0.5 + 2(2.0381)\big] \approx 0.697024T4​=0.125[1+0.5+2(2.0381)]≈0.697024.
  3. Mid-ordinates. At 1.1251.1251.125, 1.3751.3751.375, 1.6251.6251.625, 1.8751.8751.875, the values add to 2.76492.76492.7649, so M4≈0.691220M_4 \approx 0.691220M4​≈0.691220.
  4. Compare. T4T_4T4​ is about 0.00390.00390.0039 too big and M4M_4M4​ about 0.00190.00190.0019 too small.

Too big or too small?

Two panels with the same upward-bending curve over four strips. On the left, the trapezium rule: straight chords join the tops of the ordinates, and each chord lies above the curve. On the right, the mid-ordinate rule: rectangles whose tops are at the height of the curve at the middle of each strip, each with a dashed tangent at that point lying below the curve.

If the curve bends upwards on [a,b][a, b][a,b], that is f′′>0f'' > 0f′′>0 (the curve is convex), every chord lies above the curve. So the trapezium rule is too big. The tangent at a midpoint lies below the curve, and the mid-ordinate rectangle has the same area as the trapezium under that tangent. So the mid-ordinate rule is too small. If the curve bends downwards, both statements turn round. A sketch of the curve tells you which way each estimate is wrong.

How large is the error?

For a function with a continuous second derivative,

∫abf dx−Tn=−(b−a)h212f′′(ξ),\displaystyle \int_a^b f\,dx - T_n = -\dfrac{(b - a)h^2}{12}f''(\xi),∫ab​fdx−Tn​=−12(b−a)h2​f′′(ξ),
∫abf dx−Mn=(b−a)h224f′′(η),\displaystyle \int_a^b f\,dx - M_n = \dfrac{(b - a)h^2}{24}f''(\eta),∫ab​fdx−Mn​=24(b−a)h2​f′′(η),

for some ξ\xiξ and η\etaη in [a,b][a, b][a,b]. Three facts follow.

  • Both errors are proportional to h2h^2h2. Halving hhh divides each error by about 444.
  • The mid-ordinate error is about half the trapezium error, with the opposite sign.
  • If ∣f′′(x)∣≤K|f''(x)| \le K∣f′′(x)∣≤K on [a,b][a, b][a,b], then ∣ET∣≤(b−a)h2K12|E_T| \le \dfrac{(b - a)h^2 K}{12}∣ET​∣≤12(b−a)h2K​.

So we can choose nnn in advance. For ∫12dxx\int_1^2 \dfrac{dx}{x}∫12​xdx​, f′′(x)=2x3≤2f''(x) = \dfrac{2}{x^3} \le 2f′′(x)=x32​≤2. For an error below 10−410^{-4}10−4 we need h26<10−4\dfrac{h^2}{6} < 10^{-4}6h2​<10−4, so h<0.0245h < 0.0245h<0.0245 and n≥41n \ge 41n≥41.

Practise with new numbers

Try it in Python

The program applies both rules to ∫12dxx\int_1^2 \dfrac{dx}{x}∫12​xdx​ with 222, 444, 888 and 161616 strips, and prints how much each error shrinks.

Read it first. Then run it. By what factor does each error shrink when n doubles?

1. Change the function to math.sqrt(x), which bends downwards. What happens to the signs of the errors?

2. Add a column for (2 * M + T) / 3. How small are its errors?

Common mistakes

  • Counting strips and ordinates as one. nnn strips need n+1n + 1n+1 ordinates.
  • Doubling the end ordinates. Only the inner ordinates count twice.
  • Using ends in the mid-ordinate rule. The heights are taken at the middles of the strips.
  • The wrong direction. For f′′>0f'' > 0f′′>0, the trapezium rule is too big, not too small.

Remember these

  • Tn=h2[ends+2×inner]T_n = \tfrac{h}{2}[\text{ends} + 2 \times \text{inner}]Tn​=2h​[ends+2×inner].
  • Mn=h×M_n = h \timesMn​=h× (sum of the mid-ordinates).
  • Convex curve: TTT too big, MMM too small.
  • Errors in proportion to h2h^2h2: halve hhh, quarter the error.

Check yourself

Try each one on your own first. If you are stuck, open a hint. Then check with Show the answer.

  1. Estimate ∫02x3 dx\int_0^2 x^3\,dx∫02​x3dx by the trapezium rule with 222 strips. Is it too big or too small?
  1. A curve bends downwards on [a,b][a, b][a,b]. Which rule gives an estimate that is too big?
  1. With nnn strips the trapezium error is 0.020.020.02. Roughly what is it with 2n2n2n strips?
  1. Why is the trapezium rule exact for a straight line?
  1. A table has 999 ordinates. How many strips does the trapezium rule use?

References

  • OpenStax, Calculus Volume 2, Section 3.6, Numerical Integration.
  • R. L. Burden and J. D. Faires, Numerical Analysis, Chapter 4, Numerical Differentiation and Integration.

Enroll free in Numerical Integration and Hyperbolic Substitutions

Every lesson is open to read. Enrolling also lets you:

  • Mark lessons done and carry on where you stopped.
  • Take the tests of this lesson and its course.
  • Count the course towards the certificate for its chapter.
No payment. You can leave at any time.

Problems (3)

A test driver starts from rest and records the speed of a car every 10 s for one minute: Use the…Hard · High School (11–12) · by StemPy Lab
Let f'' > 0 on [a, b]. Prove that on one strip, M₁ < ∫aᵇ f dx < T₁…Advanced · High School (11–12) · by StemPy Lab
An engineer must find ∫₁³ ln x dx with an error of less than 0.0005, and wants to know how much…Hard · High School (11–12) · by StemPy Lab
Next: lesson 2Simpson's rule and error estimates
← Numerical Integration and Hyperbolic Substitutions
← PreviousSimpson's rule and error estimates →

Discussion (0)

Log in to join the discussion.

Loading…

1 Python program
5 questions to check yourself

This lesson is free to read. Enroll free to keep your place and take the tests.

Python Labs (1)

Trapezium and mid-ordinate rulesPython Lab · by StemPy Lab