Before explaining what the Simpson's methods are used for and give an example, it is necessary to give the definition of numerical method.

A numerical method is a mathematical technique used for solving mathematical problems that cannot be solved or are difficult to solve analytically. To solve a problem analytically is to give an exact answer in the form of a mathematical expression.

In other words, a numerical method is an algorithm that converges to a solution that approximates to the exact answer. This solution is called *numerical solution*.

So, let's start with the main topic. Simpson's methods are used for approximating the value of an integral I( *f* ) of a function *f*(*x*) over an interval from *a* to *b* using quadratic (Simpson's 1/3 method) and cubic (Simpson's 3/8 method) polynomials. These methods are used when analytical integration is difficult or not possible, and when the integrand is given as a set of discrete points.

Simpson's 1/3 method uses a quadratic polynomial to approximate the integrand. We need three points to determine the coefficients of this polynomial. These points are

x_{1}=a,x_{3}=bandx_{2}= (a+b)/2The name 1/3 in the method comes from the factor in the expression.

If you want a more accurate evaluation of the integral with this method, you can use the composite Simpson's 1/3 method in which you must divide the whole interval into

nsubintervals using an even number, because Simpson's 1/3 method needs three points for defining a quadratic polynomial, that means that this method applies two adjacent subintervals at a time.Where, the subintervals

nmust be equally space. Andh= (b-a)/n

Simpson's 3/8 method uses a cubic polynomial to approximate the integrand. We need four points to determine the coefficients of this polynomial. These points are

x_{1}=a,x_{2}=a+h,x_{3}=a+2handx_{4}=bThe name 3/8 in the method comes from the factor in the expression.

If you want a more accurate evaluation of the integral with this method, you can use the composite Simpson's 3/8 method in which you have to divide the whole interval into a number

nof subintervals that is divisible by 3, because Simpson's 3/8 method need four points for constructing a cubic polynomial, that mean that this method applies three adjacent subintervals at a time.Where, the subintervals

nmust be equally space. Andh= (b-a)/n

These methods are applied in the real world to calculate areas, volumes, curve lengths and other problems related to integrals.

For example: the company ECO wants to drain and fill a polluted marsh (see the image below) that has a depth of 5 feet. The CEO of ECO wants to know how many cubic feet of land are needed to fill the area after draining the marsh.

To solve this problem I used the composite Simpson's 1/3 method.

```
fn simpson(a: f64, b: f64, n: i32) -> f64 {
let mut y: f64 = funcion(a) + funcion(b);
let mut x: f64 = a;
let h: f64 = (b-a)/(n as f64);
for i in 1..n {
x = x + h;
if i % 2 == 0{
y= y + 2.0*funcion(x);
}else{
y= y + 4.0*funcion(x);
}
}
return (b-a) * y / (3.0*(n as f64));
}
```

Solution: To calculate the volume of the marsh, we must first estimate the surface area using the composite Simpson's 1/3 method.

```
let mut resultado: i32 = simpson(vec![146, 122, 76, 54, 40, 30, 13], 20);
fn simpson(v: Vec<i32>, h: i32) -> i32 {
let mut y: i32 = 0;
let mut con: i32 = 0;
let size: usize = v.len()-1;
for i in v {
if con == 0{
y = y + i;
}else if con == (size as i32) {
y = y + i;
}else{
if con % 2 == 0{
y= y + 2*i;
}else{
y= y + 4*i;
}
}
con = con +1;
}
return h*y/3;
}
```

And finally multiply by 5.

```
resultado = resultado * 5;
```

Obtaining that the approximate volume is `40 500 cubic feet`

.

In conclusion, integration with numerical methods is a useful technique when we try to integrate a complicated function or if we only have tabulated data. With the Simpson's methods we can approximate a complex integral to the integral of a polynomial and obtain a solution that approximates the exact answer, even in some cases we can obtain the exact answer.

### References

- Gilat A., Subramaniam, V. (2013). Numerical methods for engineers and scientists. Wiley. Third Edition.
- Heath M., (2002). Scientific Computing: An Introductory Survet. McGraw Hill. Second Edition.
- Chapra, S., Canale, R. (2011). Métodos Numéricos para ingenieros. McGraw Hill. Sexta edición.

### Additional resources

- Numerical Methods repository in GitHub, by LindaEliza.

Posted on May 12 '18 by:

## Discussion