Simpson’s 3 8 Method C Code

I will share the Simpson’s 3 8 Method C Code. There are other methods that can calculate the integration more accurate but today I’ll share one of my class notes which can be helpful who is looking for an easy implementation of this method. The function that I use for this program is ex whose integration is same as itself. You can implement your custom function easily overriding  f(double x) prototype. Program requires lower, upper bound of integration and the n ( part count ) as an input. You can get more accurate results when you give n is high enough. Because the method is applied each part independently. You can check out code of the program below. The method detailed information.

An example output when you run the program above.

Lower Bound : 1

Upper Bound : 4

n : 18

simpson's 3 8

Result of the integration is : 51.8798740205

When you take the original function integration it gives us 51.8798682046852.

It shows that fault tolerance is in 4 decimal precision. When we give n : 100

The result becomes more accurate like 51.8798682108.