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. /Simpson's rule and error estimates

Course 34.3·Lesson 2 of 3

Simpson's rule and error estimates

Simpson's rule fits a parabola through each pair of strips. It needs an even number of strips and gives the weights 1,4,2,4,…,2,4,11, 4, 2, 4, \ldots, 2, 4, 11,4,2,4,…,2,4,1

Lesson 2 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 Simpson's rule from a formula or a table;
  • explain why it is exact for cubics and how its error depends on hhh;
  • improve trapezium estimates by Richardson's method and judge how accurate a result is.

Bend the tops

The trapezium rule uses straight tops. A curve is rarely straight, but over a short piece it looks very like a parabola. So fit a parabola through three neighbouring points, and use the area under it.

Simpson's rule

Through the points at x=−hx = -hx=−h, 000 and hhh, with heights y0y_0y0​, y1y_1y1​, y2y_2y2​, there is one parabola. The area under it is

∫−hh(A+Bx+Cx2) dx=2Ah+23Ch3.\displaystyle \int_{-h}^{h} (A + Bx + Cx^2)\,dx = 2Ah + \tfrac{2}{3}Ch^3.∫−hh​(A+Bx+Cx2)dx=2Ah+32​Ch3.

Since y0+y2=2A+2Ch2y_0 + y_2 = 2A + 2Ch^2y0​+y2​=2A+2Ch2 and y1=Ay_1 = Ay1​=A, this equals h3(y0+4y1+y2)\dfrac{h}{3}(y_0 + 4y_1 + y_2)3h​(y0​+4y1​+y2​). Repeating over pairs of strips gives Simpson's rule, for an even nnn:

Sn=h3[y0+yn+4(y1+y3+⋯ )\displaystyle S_n = \dfrac{h}{3}\big[y_0 + y_n + 4(y_1 + y_3 + \cdots)Sn​=3h​[y0​+yn​+4(y1​+y3​+⋯)
+2(y2+y4+⋯ )].\displaystyle \qquad + 2(y_2 + y_4 + \cdots)\big].+2(y2​+y4​+⋯)].

The weights run 1,4,2,4,2,…,4,11, 4, 2, 4, 2, \ldots, 4, 11,4,2,4,2,…,4,1. For ∫12dxx\int_1^2 \dfrac{dx}{x}∫12​xdx​ with 444 strips, S4≈0.693254S_4 \approx 0.693254S4​≈0.693254, only about 0.00010.00010.0001 above ln⁡2\ln 2ln2.

A curve over two strips from -h to h, with its three ordinates y0, y1 and y2 marked. A dashed parabola passes through the three tops and nearly matches the curve. Labels give the weights 1, 4 and 1 under the three ordinates.

Exact for cubics

The rule is built to be exact for parabolas. It is exact for cubics too. On [−h,h][-h, h][−h,h], the term Dx3Dx^3Dx3 is odd, so its integral is 000, and its values at −h-h−h, 000, hhh add, with the weights 1,4,11, 4, 11,4,1, to −Dh3+0+Dh3=0-Dh^3 + 0 + Dh^3 = 0−Dh3+0+Dh3=0. Both sides gain nothing. For f′′′′f''''f′′′′ continuous, the error is

∫abf dx−Sn=−(b−a)h4180f′′′′(ξ).\displaystyle \int_a^b f\,dx - S_n = -\dfrac{(b - a)h^4}{180}f''''(\xi).∫ab​fdx−Sn​=−180(b−a)h4​f′′′′(ξ).

The error is proportional to h4h^4h4. Halving hhh divides it by about 161616.

Two rules make a third

Look at the errors of the last lesson: the error of MnM_nMn​ is about −12-\tfrac{1}{2}−21​ times the error of TnT_nTn​. A weighted average cancels them:

S2n=2Mn+Tn3.\displaystyle S_{2n} = \dfrac{2M_n + T_n}{3}.S2n​=32Mn​+Tn​​.

This is exactly Simpson's rule with 2n2n2n strips. In the same way, the error of T2nT_{2n}T2n​ is about a quarter of the error of TnT_nTn​, and

4T2n−Tn3=S2n.\displaystyle \dfrac{4T_{2n} - T_n}{3} = S_{2n}.34T2n​−Tn​​=S2n​.

This trick of removing the leading error is Richardson's extrapolation. Applied again and again, it is Romberg's method.

How do we know an answer is right?

In practice we do not know the exact value. So we compute SnS_nSn​ and S2nS_{2n}S2n​ and compare them. The error of S2nS_{2n}S2n​ is about 115\tfrac{1}{15}151​ of their difference. If the difference is 3×10−53 \times 10^{-5}3×10−5, the error of S2nS_{2n}S2n​ is about 2×10−62 \times 10^{-6}2×10−6.

A worked example from a table

A tank is filled through a pipe. The rate of flow is read every 555 minutes:

Time (min)Rate (L/min)
000121212
555151515
101010171717
151515161616
202020131313
  1. The strips. h=5 minh = 5\ \text{min}h=5 min and n=4n = 4n=4, which is even.
  2. Simpson. 53[12+13+4(15+16)+2(17)] L=53×183 L=305 L\dfrac{5}{3}\big[12 + 13 + 4(15 + 16) + 2(17)\big]\ \text{L} = \dfrac{5}{3} \times 183\ \text{L} = 305\ \text{L}35​[12+13+4(15+16)+2(17)] L=35​×183 L=305 L.
  3. Trapezium, to compare. 52[12+13+2(48)] L=302.5 L\dfrac{5}{2}\big[12 + 13 + 2(48)\big]\ \text{L} = 302.5\ \text{L}25​[12+13+2(48)] L=302.5 L.
  4. Read it. The rate curve bends downwards, so the trapezium value is too small, as expected.

Practise with new numbers

Try it in Python

The program applies Simpson's rule to ∫12dxx\int_1^2 \dfrac{dx}{x}∫12​xdx​ with more and more strips, and checks that the error falls by about 161616 each time.

Read it first. Then run it. What is the ratio of successive errors?

1. Try the cubic x ** 3 - 2 * x. What are the errors now, and why?

2. Put 5 in the list of strip numbers. What does the program say, and why must n be even?

Common mistakes

  • An odd number of strips. Simpson's rule pairs the strips, so nnn must be even.
  • The weights in the wrong places. The odd-numbered inner ordinates get 444, the even-numbered ones 222.
  • h2\tfrac{h}{2}2h​ in place of h3\tfrac{h}{3}3h​ at the front.
  • Halving hhh and expecting a quarter of the error. For Simpson it is about a sixteenth.

Remember these

  • Sn=h3[ends+4×odd+2×even]S_n = \tfrac{h}{3}[\text{ends} + 4 \times \text{odd} + 2 \times \text{even}]Sn​=3h​[ends+4×odd+2×even], nnn even.
  • Exact for cubics; error in proportion to h4h^4h4.
  • S2n=2Mn+Tn3=4T2n−Tn3S_{2n} = \dfrac{2M_n + T_n}{3} = \dfrac{4T_{2n} - T_n}{3}S2n​=32Mn​+Tn​​=34T2n​−Tn​​.
  • Error of S2nS_{2n}S2n​ is about 115(S2n−Sn)\tfrac{1}{15}(S_{2n} - S_n)151​(S2n​−Sn​).

Check yourself

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

  1. Use Simpson's rule with 222 strips on ∫02x3 dx\int_0^2 x^3\,dx∫02​x3dx.
  1. With T2=0.75T_2 = 0.75T2​=0.75 and M2=0.6M_2 = 0.6M2​=0.6, what is S4S_4S4​?
  1. With n=4n = 4n=4, Simpson's error is 8×10−58 \times 10^{-5}8×10−5. Estimate the error with n=8n = 8n=8.
  1. A table has 888 ordinates. Can you use Simpson's rule on all of it?
  1. Why is 4T2n−Tn3\tfrac{4T_{2n} - T_n}{3}34T2n​−Tn​​ better than T2nT_{2n}T2n​?

References

  • OpenStax, Calculus Volume 2, Section 3.6, Numerical Integration.
  • R. L. Burden and J. D. Faires, Numerical Analysis, Chapter 4, Romberg 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 hydrologist measures the depth of a river at points 2 m apart across a channel 12 m wide: Use…Hard · High School (11–12) · by StemPy Lab
Prove that Simpson's rule with 2 strips is exact for every cubic f(x) = A + Bx + Cx² + Dx³ on [-h…Advanced · High School (11–12) · by StemPy Lab
The integral ∫₀¹ 4/(1 + x²) dx is exactly π, because d/dx tan⁻¹ x = 1/(1 + x²)…Advanced · High School (11–12) · by StemPy Lab
Next: lesson 3Integrals by hyperbolic substitution
← Numerical Integration and Hyperbolic Substitutions
← The trapezium and mid-ordinate rulesIntegrals by hyperbolic substitution →

Discussion (0)

Log in to join the discussion.

Loading…

. It is exact for every cubic, and its error falls like
h4h^4h4
, so halving the strip width divides the error by about
161616
. It can also be built from the other two rules:
S2n=2Mn+Tn3=4T2n−Tn3S_{2n} = \dfrac{2M_n + T_n}{3} = \dfrac{4T_{2n} - T_n}{3}S2n​=32Mn​+Tn​​=34T2n​−Tn​​
.
about 25 min1 simulation2 practice questions1 Python program5 questions to check yourself

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

Python Labs (1)

Simpson's rule and Richardson's trickPython Lab · by StemPy Lab