20 January 2020 01:01:48 PM LINE_NCO_RULE_TEST C version: Test the LINE_NCO_RULE library. TEST01 LINE_NCO_RULE computes the Newton-Cotes Open (NCO) rule using N equally spaced points for an interval [A,B]. Newton-Cotes Open (NCO) Rule #1 I X(I) W(I) 0 0 2 Sum(|W)|) = 2 Newton-Cotes Open (NCO) Rule #2 I X(I) W(I) 0 -0.333333 1 1 0.333333 1 Sum(|W)|) = 2 Newton-Cotes Open (NCO) Rule #3 I X(I) W(I) 0 -0.5 1.33333 1 0 -0.666667 2 0.5 1.33333 Sum(|W)|) = 3.33333 Newton-Cotes Open (NCO) Rule #4 I X(I) W(I) 0 -0.6 0.916667 1 -0.2 0.0833333 2 0.2 0.0833333 3 0.6 0.916667 Sum(|W)|) = 2 Newton-Cotes Open (NCO) Rule #5 I X(I) W(I) 0 -0.666667 1.1 1 -0.333333 -1.4 2 0 2.6 3 0.333333 -1.4 4 0.666667 1.1 Sum(|W)|) = 7.6 Newton-Cotes Open (NCO) Rule #6 I X(I) W(I) 0 -0.714286 0.848611 1 -0.428571 -0.629167 2 -0.142857 0.780556 3 0.142857 0.780556 4 0.428571 -0.629167 5 0.714286 0.848611 Sum(|W)|) = 4.51667 Newton-Cotes Open (NCO) Rule #7 I X(I) W(I) 0 -0.75 0.973545 1 -0.5 -2.01905 2 -0.25 4.64762 3 0 -5.20423 4 0.25 4.64762 5 0.5 -2.01905 6 0.75 0.973545 Sum(|W)|) = 20.4847 Newton-Cotes Open (NCO) Rule #8 I X(I) W(I) 0 -0.777778 0.797768 1 -0.555556 -1.25134 2 -0.333333 2.21741 3 -0.111111 -0.763839 4 0.111111 -0.763839 5 0.333333 2.21741 6 0.555556 -1.25134 7 0.777778 0.797768 Sum(|W)|) = 10.0607 Newton-Cotes Open (NCO) Rule #9 I X(I) W(I) 0 -0.8 0.891755 1 -0.6 -2.57716 2 -0.4 7.35009 3 -0.2 -12.1407 4 0 14.9519 5 0.2 -12.1407 6 0.4 7.35009 7 0.6 -2.57716 8 0.8 0.891755 Sum(|W)|) = 60.8713 Newton-Cotes Open (NCO) Rule #10 I X(I) W(I) 0 -0.818182 0.758509 1 -0.636364 -1.81966 2 -0.454545 4.3193 3 -0.272727 -4.70834 4 -0.0909091 2.45019 5 0.0909091 2.45019 6 0.272727 -4.70834 7 0.454545 4.3193 8 0.636364 -1.81966 9 0.818182 0.758509 Sum(|W)|) = 28.112 Newton-Cotes Open (NCO) Rule #11 I X(I) W(I) 0 -0.833333 0.83342 1 -0.666667 -3.09706 2 -0.5 10.6544 3 -0.333333 -23.0561 4 -0.166667 37.0525 5 0 -42.7742 6 0.166667 37.0525 7 0.333333 -23.0561 8 0.5 10.6544 9 0.666667 -3.09706 10 0.833333 0.83342 Sum(|W)|) = 192.161 Newton-Cotes Open (NCO) Rule #12 I X(I) W(I) 0 -0.846154 0.727116 1 -0.692308 -2.35157 2 -0.538462 7.03889 3 -0.384615 -11.9379 4 -0.230769 13.1062 5 -0.0769231 -5.58266 6 0.0769231 -5.58266 7 0.230769 13.1062 8 0.384615 -11.9379 9 0.538462 7.03889 10 0.692308 -2.35157 11 0.846154 0.727116 Sum(|W)|) = 81.4887 TEST02 Use a sequence of NCO rules to compute an estimate Q of the integral: I = integral ( 0 <= x <= 1 ) exp(x) dx. The exact value is: I = 1.71828 N Q |Q-I| 1 1.64872 0.0695606 2 1.67167 0.0466086 3 1.71778 0.000505296 4 1.71793 0.00035166 5 1.71828 1.73578e-06 6 1.71828 1.22681e-06 7 1.71828 3.44711e-09 8 1.71828 2.45789e-09 9 1.71828 4.95142e-11 10 1.71828 9.79866e-10 11 1.71828 1.80838e-09 12 1.71828 4.10579e-08 13 1.71828 2.30888e-07 14 1.71828 1.92466e-06 15 1.71829 3.18399e-06 16 1.71825 2.75244e-05 17 1.71817 0.00011216 18 1.71263 0.00565305 19 1.71834 5.48642e-05 20 1.73082 0.0125421 21 2.26518 0.546896 22 2.57597 0.857689 LINE_NCO_RULE_TEST Normal end of execution. 20 January 2020 01:01:48 PM