Skip to content
geeksforgeeks
  • Tutorials
    • Python
    • Java
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
    • Practice Coding Problems
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Number System and Arithmetic
  • Algebra
  • Set Theory
  • Probability
  • Statistics
  • Geometry
  • Calculus
  • Logarithms
  • Mensuration
  • Matrices
  • Trigonometry
  • Mathematics
Open In App
Next Article:
Simpson's Rule Formula
Next article icon

Simpson's Rule Formula

Last Updated : 06 Aug, 2024
Comments
Improve
Suggest changes
Like Article
Like
Report

A way of finding the area of any figure is by integrating the function of that curve within the required limits which gives the area under that curve. However, there is a problem with this approach as in some cases the integral of the function can not be calculated or is difficult to find. It should also be noted that in many real-life engineering situations finding an approximate value of the area can be sufficient. This is where Simpson's formula comes into the picture. 

The area under the curve

Table of Content

  • Simpson's Rule Formula
  • Derivation of Simpson's rule formula
    • Error bound in Simpson's Rule
    • Related Articles
  • Sample Problems on Simpson's Rule Formula
  • Practice Problems on Simpson's Rule Formula

Simpson's Rule Formula

The Simpson's rule formula is a mathematical formula given by British mathematician Thomas Simpson, which approximates the value of a definite integral. The rule states that :

\int_{a}^{b} f(x) \,dx   ≈ Sn

Where Sn = \frac{\Delta}{3}[f(x_0)+4f(x_1)+2f(x_2)+4f(x_3)+...+2f(x_{n-2})+4f(x_{n-1})+f(x_n)]         .

Here \Delta=b-a   , a=x0 and b = xn, \Delta=\frac{b-a}{n}  , n = any even integer.

Derivation of Simpson's rule formula

For a better understanding of how Simpson's formula helps in approximating the area let's derive the actual formula. Consider a function y = f(x) which is continuous in the closed interval [a, b]. We are going to approximate the value of integral \int_{a}^{b}{f(x)dx}   by dividing the area under the curve into parabolas. For doing this divide the interval [a,b] into sub-intervals [x0, x1], [x1, x2], [x2, x3],...,[xn-2, xn-1], [xn-1, xn] each of width\Delta  . Here x0 = a and xn = b. Now for finding the area let's suppose that a parabola passes through every three consecutive points on the curve, i.e. there is a parabola that passes through points (x0, f(x0)), (x1, f(x1)), (x2, f(x2)). 

Parabola passing through three points taken out of the curve

Next we make this parabola symmetric along the y-axis. Lets assume the equation of this parabola to be px2 + qx + r.

Parabola made symmetric along the y-axis

Now the area from x0 to x2 can be found by the definite integral \int_{-\Delta}^{\Delta}   (px2 + qx + r)dx.

 \int_{-\Delta}^{\Delta} (px^2 +qx+r)dx = \frac{px^3}{3}+\frac{qx^2}{2} +rx |^{\Delta}_{-\Delta}     .

= 2p\frac{\Delta^3}{3}   +0 +2r\Delta  .

=\frac{\Delta}{3}[2p{\Delta}^2 +6r]  ⇢ (1)

Also, f(x0) = p(\Delta)^2 -q(\Delta) +r  .

f(x1) =  r [since x1 = 0]

f(x2) = p(\Delta)^2 +q(\Delta) +r  .

Now f(x_0) +4f(x_1) +f(x_2) = [2p{\Delta}^2 +6r]  . ⇢  (2)

Compare (1) and (2),

\int_{-\Delta}^{\Delta} (px^2 +qx+r)dx = f(x_0) +4f(x_1) +f(x_2)

This means that, Area between x₀ and x₂ = f(x0​)+4f(x1​)+f(x2​)

Similarly we can find the area between the points x2 and x4. =  \Delta/3 (f(x₂) + 4f(x₃) + f(x₄))     .

We can now calculate the other areas in a similar way.           

\frac{\Delta}{3}[f(x_0)+4f(x_1)+2f(x_2)+4f(x_3)+...+2f(x_{n-2})+4f(x_{n-1})+f(x_n)].  

Error bound in Simpson's Rule

As mentioned earlier Simpson's rule is helpful only for finding the approximate value of the integral. there is always an error bound in the calculation which is given by 

 \frac{M(b-a)^5}{180n^4}

Here M>|f4(x)|

Related Articles:

  • Simpson's Rule in MATLAB
  • Program for Simpson's 1/3 Rule
  • Real Life Applications of Simpsons Rules

Sample Problems on Simpson's Rule Formula

Question 1: Find the integral \int_{0}^{4} x^4 dx   for n = 4. 

Solution: 

Here f(x) = x4, a = 0, b = 4 and n = 4, \Delta=1  .

By Simpson's formula, \int_{0}^{4} x^4dx =\frac{\Delta}{3}[0^4+4(1^4)+2(2^4)+4(3^4)+(4^4)]       .

= (1 + 4 + 32 + 324 + 256)/3 = 205.66

Note: This solution provided by Simpson's formula is only an approximation the actual value of the integral will be 204.8. In later examples, we will see how this rule is helpful for finding the definite integral of functions whose integral we are unable to find.

Question 2: Find the integral  \int_{0}^{π} cosx dx   for n = 4

Solution:

 Here f(x) = cos x a = 0, b = π, n = 4 and \Delta =π/4  .

By Simpson's formula \int_{0}^{π}cos(x)dx =\frac{\Delta}{3}[cos(0)+4cos(π/4)+2cos(π/2)+4cos(3π/4)+cos(π)]  .

= 0/3 = 0.

Question 3: Solve for the integral \int_{0}^{2} e^{x^3} dx   for n = 2.

Solution: 

Here f(x)= e^{x^3}   , a = 0, b = 2, n = 2 and \Delta   = 2 - 0/2 = 1.

Using Simpson's formula \int_{0}^{2}e^{x^3} dx= \frac{\Delta}{3}[e^{0^3}+4e^{1^3}+e^{2^3}]  .

=\frac{[e^0+4e^1+e^8]}{3}  .

= 2988.6762/3 = 995.8920

Note: The indefinite integral of the function, in this case, cannot be found. However, we could have used the limit of sums method for finding the integral but since it requires a lot more calculations, therefore, Simpson's formula is preferred. 

Question 4: Solve for the integral \int_{e^2}^{2e^2} lnx dx   where n = 4.

Solution:

Here f(x) = ln x, a= e2, b = 2e2, n = 4 and \Delta= \frac{e^2}{4}.

Applying the Simpson's formula \int_{e^2}^{2e^2}ln x dx =\frac{\Delta}{3}[ln(e^2)+4ln(\frac{5}{4}e^2)+2ln(\frac{3}{2}e^2)+4ln(\frac{7}{4}e^2)+ln(2e^2)]  .

=\frac{e^2}{12}  [2 + 4ln5 - 4ln4 + 8 + 2ln3 - 2ln2 + 4 + 4ln7 - 4ln4 + 8 + 2ln2 + 4].

= 15.3159106.

Question 5: Find the integral  \int_{0}^{π} sin^2 x dx   where n = 4.

Solution: 

Here f(x) = sin2x, a = 0, b = π, n = 4 and \Delta  = π/4.

Using Simpson's formula \int_{0}^{π}sin^2(x)dx=\frac{π/4}{3}[sin^2(0)+ 4sin^2(π/4)+ 2sin^2(π/2)+ 4sin^2(3π/4) +sin^2(π)]  .

= π/12[2 + 2 + 2]

= π/2

Question 6: Integrate the function x cos x between the limits 0 to \frac{\pi}{2}   using Simpson's rule and check the accuracy by calculating the actual integral. (Take n = 4).

Solution:

We need to find the integral \int_{0}^{\frac{\pi}{2}} x cos x dx  .

Using Simpson's formula for n = 4.

\int_{0}^{\frac{\pi}{2}}x cos(x)dx=\frac{π/8}{3}[0 \times cos(0)+ 4 \times \frac{\pi}{8} cos(π/8)+ 2 \times \frac{\pi}{4}(π/4)+ 4 \times \frac{3 \pi}{8} cos(3π/8) +\frac{\pi}{2}cos(π/2)]    .

= 0.89

Now

\int_{0}^{\frac{\pi}{2}} x cosx = x sinx +cosx   .

xsinx +cosx |_{0}^{\frac{\pi}{2}}  .

= \frac{\pi}{2}   - 1 = 0.57 .

So the difference between the Simpson value  and the actual  value of the integral = 0.89-0.57 = 0.32.

Question 7: Given a function f(x) = x cos (x) check the accuracy of Simpson's rule formula for n = 2 and n = 4 within the limits 0 and π/2.

Solution:

Let's check the value of the integral by using Simpson's formula for n = 4

\int_{0}^{\frac{\pi}{2}}x cos(x)dx=\frac{π/8}{3}[0 \times cos(0)+ 4 \times \frac{\pi}{8} cos(π/8)+ 2 \times \frac{\pi}{4}(π/4)+ 4 \times \frac{3 \pi}{8} cos(3π/8) +\frac{\pi}{2}cos(π/2)]   .

= 0.8879

Now let's apply the Simpson's rule on the same integral but this time for n=2

\int_{0}^{\frac{\pi}{2}}x cos(x)dx=\frac{π/4}{3}[0 \times cos(0)+ 4 \times \frac{\pi}{4} cos(π/4)+ \frac{\pi}{2}cos(π/2)]     .

= \frac {\pi}{12} [\pi \times \sqrt 2]    .

= 0.583

Now the value of the integral varies significantly as you change the value of n. The accuracy of the Simpson's rule depends on the value of n. This shows that Simpson's rule depends on the value of n it is mostly advised to take the value of n = 4.

Practice Problems on Simpson's Rule Formula

  1. Find the integral  \int_{0}^{3} x^2 dx  using Simpson's rule for n = 6.
  2. Calculate \int_{1}^{5} e^x dx  for n = 4.
  3. Evaluate \int_{0}^{π/2} sinx dx using Simpson's rule with n = 4.
  4. Find \int_{1}^{4} lnx dx  for n = 4.
  5. Solve \int_{0}^{2} x^3 dx  using Simpson's rule for n = 4.
  6. Calculate \int_{0}^{1} 1/1+x^2 dx  using n = 4.
  7. Evaluate \int_{0}^{π/4} tanx dx for n = 4.
  8. Find \int_{0}^{1} e^-x^2 dx  using Simpson's rule for n = 4.
  9. Solve \int_{0}^{3} cos^2x dx  for n = 4.
  10. Calculate \int_{1}^{3} 1/x dx  using n = 4.

Next Article
Simpson's Rule Formula

H

harmansahani100
Improve
Article Tags :
  • Mathematics
  • School Learning
  • Maths MAQ
  • Maths-Formulas

Similar Reads

    Simpson's Rule in MATLAB
    Simpson’s 1/3 rule is a numerical method used for the evaluation of definite integrals. MATLAB does not provide an in-built function to find numerical integration using Simpson's rule. However, we can find that using the below formula.The formula for numerical integration using Simpson's rule is:whe
    2 min read
    Snell's Law Formula
    Snell's law explains the relationship between the angle of refraction, incidence, and the refractive law of indices for the specified media such as light, glass, and air. It asserts that the ratio of the sines of the angle of incidence 1 and angle of refraction 2 for a given set of media is equal to
    4 min read
    Reduction Formula
    Reduction formula in mathematics is generally used for solving integration of higher order. Integration involving higher-order terms is difficult to handle and solve. So, to simplify the solving process of higher-order terms and get rid of the lengthy expression-solving process of higher-order degre
    4 min read
    Point Gradient Formula
    A straight line in a cartesian plane passes through an infinite number of points. Each of these points has its own x and y- coordinates. The points a line passes through are used to find its slope. Not only that but such points can also be used to write the equation of a line. One such method is dis
    4 min read
    Recursive Formula
    A recursive function is a function that defines each term of a sequence using the previous term i.e., The next term is dependent on one or more known previous terms. Recursive function h(x) is written as,h(x) = a0h(0) + a1h(1) + a2h(2) + ... + ax - 1h(x - 1)where, ai ≥ 0i = 0, 1, 2, 3, ... ,(x - 1)T
    4 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences