Skip to content
Related Articles
Open in App
Not now

Related Articles

Simpson’s Rule Formula

Improve Article
Save Article
  • Last Updated : 03 May, 2022
Improve Article
Save Article

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

Simpson’s Rule Formula

The Simpson’s rule formula is a mathematical formula given by British mathematician Thomas Simpson which is used for approximating 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.           


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 


Here M>|f4(x)|

Sample problems

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


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


 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.


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.


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.


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).


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


\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.


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.

My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!