double Quadrature7Points(double(*func)(double),double a,double b,int n) { if(func == NULL || n == 0){ return 0.0; }else if(n >= 1 && n <= 6){ double hh,ss; hh = (b-a)/6; ss = 41.0*FUNC(a) + 216.0*(FUNC(a+hh) + FUNC(a+5*hh)) + 27.0*(FUNC(a+2*hh) + FUNC(a+4*hh)) + 272.0*FUNC(a+3*hh) + 41.0*FUNC(b); return (hh/140)*ss; }else { double h,x,term,sum; h = (b-a)/(6*n-1); sum = 41.0*FUNC(a) + 216.0*(FUNC(a+h) + FUNC(a+5*h)) + 27.0*(FUNC(a+2*h) + FUNC(a+4*h)) + 272.0*FUNC(a+3*h) + 41.0*FUNC(b); for(int i = 1;i < n-1;i++){ x = a+6*h*i; sum += 82.0*FUNC(x) + 216.0*(FUNC(x+h) + FUNC(x+5*h)) + 27.0*(FUNC(x+2*h) + FUNC(x+4*h)) + 272.0*FUNC(x+3*h); } term = h/140; return term*sum; } }