#include stdio.h
#include conio.h
#include iostream
#include cmath
using namespace std;
double f_1(double x){
double S = log(sin(x) + x);
return S;
}
double Simp(double a, double b, double h){
double sum = f_1(a) + f_1(b);
for (double x = a + h; x < b; x += 2 * h) {
if (x + h >= b)
sum += 2 * f_1(x);
else
sum += 2 * f_1(x) + 4 * f_1(x + h);
}
return sum * h / 3.0;
}
int main(int argc, char* argv[]){
cout << Simp(2, 4, 0.001) << endl;
getch ();
return 0;
}