The compound trapezoid divides the integral range [a, B] into n equal points, step size, and product nodes. Then, the trapezoid formula is applied between each cell and sum them, it is an approximate value of the integral I. the formula is the product formula of the compound trapezoid, And the subscript n indicates that the interval n is equal. Algorithm flow algorithm code [cpp] double f (double x) {if (x = 0) return 1; else return (sin (x)/x );} double FuhuaTixing (int n, double a, double B) {double h = (B-a)/n; double x = a; double s = 0; for (int k = 0; k <n-1; k ++) {x + = h; s + = f (x);} double T = (f () + s * 2 + f (B) * h/2; return T;} int main () {char ans = 'n '; do {cout <"Enter the integral range (a, B):" <endl; double a; double B; cin> a> B; cout <"Enter the number of equal parts n:" <endl; int n; cin> n; cout <<"Result of the compound trapezoid formula ball:" <FuhuaTixing (n, a, B) <endl; cout <"do you want to continue? (Y/n) "; cin> ans;} while (ans = 'y'); return 0;} the integral range of the compound Xin Fu Sheng [, b] divide n equal points. the midpoint of the subinterval is that the Simpson formula is applied between each cell. The formula is the product formula of the compound Simpson. Algorithm flow algorithm code [cpp] double f (double x) {if (x = 0) return 1; else return (sin (x)/x );} double Xinfusheng (double a, double B, int n) {double h = (B-a)/n; double x = a + 1/2 * h; double s = 4 * f (x); for (int k = 1; k <n; k ++) {x ++ = 1/2 * h; s + = 4 * f (x); x + = 1/2 * h; s + = 2 * f (x);} double T = (f () + s + f (B) * h/6; return T;} int main () {char ans = 'n '; do {cout <"Enter the integral range (a, B):" <endl; double a; double B; cin> a> B; cout <"Enter equal parts Number n: "<endl; int n; cin> n; cout <" results from the compound trapezoid formula ball: "<Xinfusheng (a, B, n) <endl; cout <"do you want to continue? (Y/n) "; cin> ans;} while (ans = 'y'); return 0 ;} the original record of the experiment process is calculated using the compound trapezoid formula and the compound xinpu Sheng formula to calculate the definite integral n = 2, 4, 8, 16, accurate Solution: 0.9460831 experimental results and analysis 1. More accurate results can be obtained by using the complex trapezoid formula and the complex xin fu formula. The more the number of equal fractions, the higher the accuracy of the results, although the accuracy of the trapezoid formula is the same as that of the four equal fractions in 16 equal fractions, It is closer and closer to the exact solution. Because the double value in the C ++ operation has only seven valid digits, increasing the number of equal parts is not easy to see. 2. Compare the calculation results of the two methods. The function values of the five vertices must be calculated when the compound Xinfu formula is equal to two portions, the computation is basically the same as that of the compound trapezoid formula in four equal parts, but it is much more accurate to obtain the formula with obvious precision. 3. The compound trapezoid formula and the compound Xin-fu formula can obtain more accurate results for the product functions with poor smoothness. The formula is simple, which facilitates computation of simple programs by computer, therefore, it is widely used. 4. The main error in the experiment is the intercept in the floating point operation of the computer.