Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- double NewtonCotes(double a,double b, int n)
- {
- double Bk = 2.0/45;
- double h=(b-a)/n;
- double res=0;
- vector <double> coef(n+1,0);
- coef[0] = 7;
- coef[1] = 32;
- coef[2] = 12;
- coef[3] = 32;
- coef[4] = 7;
- for(int i=0;i<=n;++i)
- {
- res+=(func(a+i*h))*Bk*coef[i]*h;
- }
- return res;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement