07-Jan-2022 22:45:11 line_nco_rule_test(): MATLAB/Octave version 9.8.0.1380330 (R2020a) Update 2 Test line_nco_rule(). LINE_NCO_RULE_TEST01 LINE_NCO_RULE computes the Newton-Cotes Open rule using N equally spaced points for an interval [A,B]. Newton-Cotes Open Rule #1 I X(I) W(I) 1 0 2 Sum(|W)|) = 2 Newton-Cotes Open Rule #2 I X(I) W(I) 1 -0.333333 1 2 0.333333 1 Sum(|W)|) = 2 Newton-Cotes Open Rule #3 I X(I) W(I) 1 -0.5 1.33333 2 0 -0.666667 3 0.5 1.33333 Sum(|W)|) = 3.33333 Newton-Cotes Open Rule #4 I X(I) W(I) 1 -0.6 0.916667 2 -0.2 0.0833333 3 0.2 0.0833333 4 0.6 0.916667 Sum(|W)|) = 2 Newton-Cotes Open Rule #5 I X(I) W(I) 1 -0.666667 1.1 2 -0.333333 -1.4 3 0 2.6 4 0.333333 -1.4 5 0.666667 1.1 Sum(|W)|) = 7.6 Newton-Cotes Open Rule #6 I X(I) W(I) 1 -0.714286 0.848611 2 -0.428571 -0.629167 3 -0.142857 0.780556 4 0.142857 0.780556 5 0.428571 -0.629167 6 0.714286 0.848611 Sum(|W)|) = 4.51667 Newton-Cotes Open Rule #7 I X(I) W(I) 1 -0.75 0.973545 2 -0.5 -2.01905 3 -0.25 4.64762 4 0 -5.20423 5 0.25 4.64762 6 0.5 -2.01905 7 0.75 0.973545 Sum(|W)|) = 20.4847 Newton-Cotes Open Rule #8 I X(I) W(I) 1 -0.777778 0.797768 2 -0.555556 -1.25134 3 -0.333333 2.21741 4 -0.111111 -0.763839 5 0.111111 -0.763839 6 0.333333 2.21741 7 0.555556 -1.25134 8 0.777778 0.797768 Sum(|W)|) = 10.0607 Newton-Cotes Open Rule #9 I X(I) W(I) 1 -0.8 0.891755 2 -0.6 -2.57716 3 -0.4 7.35009 4 -0.2 -12.1407 5 0 14.9519 6 0.2 -12.1407 7 0.4 7.35009 8 0.6 -2.57716 9 0.8 0.891755 Sum(|W)|) = 60.8713 Newton-Cotes Open Rule #10 I X(I) W(I) 1 -0.818182 0.758509 2 -0.636364 -1.81966 3 -0.454545 4.3193 4 -0.272727 -4.70834 5 -0.0909091 2.45019 6 0.0909091 2.45019 7 0.272727 -4.70834 8 0.454545 4.3193 9 0.636364 -1.81966 10 0.818182 0.758509 Sum(|W)|) = 28.112 Newton-Cotes Open Rule #11 I X(I) W(I) 1 -0.833333 0.83342 2 -0.666667 -3.09706 3 -0.5 10.6544 4 -0.333333 -23.0561 5 -0.166667 37.0525 6 0 -42.7742 7 0.166667 37.0525 8 0.333333 -23.0561 9 0.5 10.6544 10 0.666667 -3.09706 11 0.833333 0.83342 Sum(|W)|) = 192.161 Newton-Cotes Open Rule #12 I X(I) W(I) 1 -0.846154 0.727116 2 -0.692308 -2.35157 3 -0.538462 7.03889 4 -0.384615 -11.9379 5 -0.230769 13.1062 6 -0.0769231 -5.58266 7 0.0769231 -5.58266 8 0.230769 13.1062 9 0.384615 -11.9379 10 0.538462 7.03889 11 0.692308 -2.35157 12 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.95146e-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. 07-Jan-2022 22:45:11