the present integral problems result in short code in more challenging engineering problems the code quickly grows to hundreds and thousands of lines without abstractions in terms of general algorithms in general reusable functionsthe complexity of the program grows so fast that it will be extremely difficult to make sure that the program works properly another advantage of packaging mathematical algorithms in functions is that function can be reused by anyone to solve problem by just calling the function with proper set of arguments understanding the function' inner details is not necessary to compute new integral similarlyyou can find libraries of functions on the internet and use these functions to solve your problems without specific knowledge of every mathematical detail in the functions this desirable feature has its downsideof coursethe user of function may misuse itand the function may contain programming errors and lead to wrong answers testing the output of downloaded functions is therefore extremely important before relying on the results the composite midpoint method the idea rather than approximating the area under curve by trapezoidswe can use plain rectangles (fig it may sound less accurate to use horizontal lines and not skew lines following the function to be integratedbut an integration method based on rectangles (the midpoint methodis in fact slightly more accurate than the one based on trapezoidsfig computing approximately the integral of function as the sum of the areas of the rectangles