The Simpson 3/8 Rule is a numerical integration method used to approximate the definite integral of a function. It is based on the approximation of the function by a cubic polynomial, using three equally spaced points.

The formula for the Simpson 3/8 Rule is:

`∫[a,b] f(x)dx ≈ 3h/8 [f(a) + 3f(a+h) + 3f(a+2h) + f(b)]`

where `h = (b-a)/3`

is the distance between the three points, and `f(a), f(a+h), f(a+2h)`

, and `f(b)`

are the function values at those points.

The Simpson 3/8 Rule is an improvement over the simpler Simpson’s Rule, which uses only two points to approximate the function with a quadratic polynomial. The Simpson 3/8 Rule has a higher degree of accuracy and is typically more accurate for smooth functions.

However, the Simpson 3/8 Rule can only be used when the number of intervals is a multiple of three. If this condition is not met, then the last interval must be approximated using another method, such as the trapezoidal rule.

## Simpson 3/8 Rule by using MATLAB Program

Simpson’s 3/8 rule is a numerical integration technique that can be used to approximate the definite integral of a function. Here’s how you can implement Simpson’s 3/8 rule in MATLAB:

- Define the function to be integrated,
`f(x)`

, as a MATLAB function. For example, let’s define the function`f(x) = x^2`

as:

```
function y = f(x)
y = x.^2;
end
```

- Define the lower and upper limits of integration,
`a`

and`b`

, and the number of intervals,`n`

. For example, let’s set`a = 0, b = 1`

, and`n = 3`

:

```
a = 0;
b = 1;
n = 3;
```

- Calculate the width of each interval,
`h`

, using the formula`h = (b-a)/n`

:

```
h = (b-a)/n;
```

- Calculate the values of
`f(x)`

at the endpoints of each interval, as well as the midpoint of each interval. Store these values in an array or matrix. For example:

```
x = linspace(a,b,n+1);
y = f(x);
```

5. Use Simpson’s 3/8 rule formula to approximate the integral of `f(x)`

over the interval` [a,b]`

. The formula is:

integral = `3h/8 * (y(1) + 3y(2) + 3y(3) + 2y(4) + 3y(5) + 3y(6) + y(7));`

In MATLAB, you can implement this formula as:

`integral = 3*h/8 * (y(1) + 3*y(2) + 3*y(3) + 2*y(4) + 3*y(5) + 3*y(6) + y(7));`

- Display the value of the approximate integral:

```
disp(integral);
```

Here’s the complete MATLAB code for the Simpson’s 3/8 rule:

```
function y = f(x)
y = x.^2;
end
a = 0;
b = 1;
n = 3;
h = (b-a)/n;
x = linspace(a,b,n+1);
y = f(x);
integral = 3*h/8 * (y(1) + 3*y(2) + 3*y(3) + 2*y(4) + 3*y(5) + 3*y(6) + y(7));
disp(integral);
```

This code will output the approximate value of the integral of `f(x)`

over the interval `[0,1] `

using Simpson’s 3/8 rule.