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
  1. Python Labs
  2. /Simpson's rule and Richardson's trick
MathematicsHardHigh School (11–12)Numerical Methods

Simpson's rule and Richardson's trick

You will write Simpson's rule, make it refuse an odd number of strips, and check that it equals Richardson's improvement of the trapezium rule.

The idea. Sn=h3[f(a)+f(b)+4(odd)+2(even)]S_n = \tfrac{h}{3}\big[f(a) + f(b) + 4(\text{odd}) + 2(\text{even})\big]Sn​=3h​[f(a)+f(b)+4(odd)+2(even)] for even nnn, and S2n=4T2n−Tn3S_{2n} = \dfrac{4T_{2n} - T_n}{3}S2n​=34T2n​−Tn​​.

Your tasks.

  1. Finish simpson(f, a, b, n). Return None when n is odd.
  2. Finish richardson(f, a, b, n). Return 4T2n−Tn3\dfrac{4T_{2n} - T_n}{3}34T2n​−Tn​​, using the trap function given.
  3. Finish strips_needed(f, a, b, exact, tol). Return the least even n for which Simpson's error is below tol.

Run it first, just as it is. The checker at the end prints FAIL for each task. Then do the tasks one at a time, and run the program again after each one. A Hint appears under every check that still fails.

When every line says PASS, compare strips_needed for Simpson with the number of trapezium strips that the same accuracy would need.

StemPy LabContributed by StemPy Lab
python
Loading Python runtime…

A worked solution

Run your code once to unlock the worked solution.

Have you tried it?

Do the tasks in the editor first, and run the checker after each one. Its hints help when a check fails. When you are ready, compare your code with this solution.

Log in to save
← All Labs
← Trapezium and mid-ordinate rulesA height finder for two stations →
More onNumerical Methods

Discussion (0)

Log in to join the discussion.

Loading…

Learn it in

  1. Simpson's rule and error estimatesNumerical Integration and Hyperbolic Substitutions

More labs on this topic

  1. Trapezium and mid-ordinate rulesHard
  2. A careful Newton solverHard
  3. A bisection solverHard
All labs on this topic →