## Simpson Method

Back to Programming

### Description

Integration is the process by which the area under a function plotted on a graph is measured. Simpson’s 1/3rd rule is the process of calculating the integration. It is an extension of the trapezoidal rule where the integral is approximated by the second-order polynomial. In this method parabola is used to approximate each part of the curve.

DERIVATION

A mechanical quadrature formula will be called closed or open according to the limits of integration are used as interpolating points or not.

Sometimes it is easy to calculate the integration by breaking the whole interval into some subintervals. After computing each subinterval we have to add it to get the actual result.

By using newton cote’s formula we get,

Then,

Hence,

Now, if we apply Newton-cote’s formula with n = 2 we can deduce Simpson’s 1/3rd formula.

Therefore,

GRAPHICAL REPRESENTATION

### Algorithm

INPUT:

OUTPUT:

The value after integrating f(x)

PROCESS:

``````Step 1: [Defining the function f(x)]
return 1/(1 + x × x)

Step 2: [Defining main function]
read x0, xn i.e. The lower limit and upper limit of the integration
read n i.e. The number of intervals
Set h ← abs(xn - x0)/n
for i = 1 to n - 1 repeat
Set x ← x0 + i × h
If i mod 2 = 0 then
Set sum ← sum + 2 × f(x)
else
Set sum ← sum + 4 × f(x)
[End of ‘if’]
[End of ‘for’]

Set result ← (h/3) × (f(x0) + f(xn) + sum))
[End of ‘main’ function]``````

### Code

1. It is better than the trapezoidal rule.

2. It approximates the curves as the series of quadratic which makes it easy to integrate.