20 January 2020 01:01:48 PM LINE_NCC_RULE_TEST C version: Test the LINE_NCC_RULE library. TEST01 LINE_NCC_RULE computes the Newton-Cotes (closed) rule using N equally spaced points for an interval [A,B]. Newton-Cotes (Closed) Rule #1 I X(I) W(I) 0 0 2 Sum(|W)|) = 2 Newton-Cotes (Closed) Rule #2 I X(I) W(I) 0 -1 1 1 1 1 Sum(|W)|) = 2 Newton-Cotes (Closed) Rule #3 I X(I) W(I) 0 -1 0.333333 1 0 1.33333 2 1 0.333333 Sum(|W)|) = 2 Newton-Cotes (Closed) Rule #4 I X(I) W(I) 0 -1 0.25 1 -0.333333 0.75 2 0.333333 0.75 3 1 0.25 Sum(|W)|) = 2 Newton-Cotes (Closed) Rule #5 I X(I) W(I) 0 -1 0.155556 1 -0.5 0.711111 2 0 0.266667 3 0.5 0.711111 4 1 0.155556 Sum(|W)|) = 2 Newton-Cotes (Closed) Rule #6 I X(I) W(I) 0 -1 0.131944 1 -0.6 0.520833 2 -0.2 0.347222 3 0.2 0.347222 4 0.6 0.520833 5 1 0.131944 Sum(|W)|) = 2 Newton-Cotes (Closed) Rule #7 I X(I) W(I) 0 -1 0.097619 1 -0.666667 0.514286 2 -0.333333 0.0642857 3 0 0.647619 4 0.333333 0.0642857 5 0.666667 0.514286 6 1 0.097619 Sum(|W)|) = 2 Newton-Cotes (Closed) Rule #8 I X(I) W(I) 0 -1 0.0869213 1 -0.714286 0.414005 2 -0.428571 0.153125 3 -0.142857 0.345949 4 0.142857 0.345949 5 0.428571 0.153125 6 0.714286 0.414005 7 1 0.0869213 Sum(|W)|) = 2 Newton-Cotes (Closed) Rule #9 I X(I) W(I) 0 -1 0.0697707 1 -0.75 0.415379 2 -0.5 -0.0654674 3 -0.25 0.740459 4 0 -0.320282 5 0.25 0.740459 6 0.5 -0.0654674 7 0.75 0.415379 8 1 0.0697707 Sum(|W)|) = 2.90243 Newton-Cotes (Closed) Rule #10 I X(I) W(I) 0 -1 0.0637723 1 -0.777778 0.351362 2 -0.555556 0.0241071 3 -0.333333 0.431786 4 -0.111111 0.128973 5 0.111111 0.128973 6 0.333333 0.431786 7 0.555556 0.0241071 8 0.777778 0.351362 9 1 0.0637723 Sum(|W)|) = 2 Newton-Cotes (Closed) Rule #11 I X(I) W(I) 0 -1 0.0536683 1 -0.8 0.355072 2 -0.6 -0.162087 3 -0.4 0.909893 4 -0.2 -0.87031 5 0 1.42753 6 0.2 -0.87031 7 0.4 0.909893 8 0.6 -0.162087 9 0.8 0.355072 10 1 0.0536683 Sum(|W)|) = 6.12959 Newton-Cotes (Closed) Rule #12 I X(I) W(I) 0 -1 0.0498665 1 -0.818182 0.309711 2 -0.636364 -0.0743385 3 -0.454545 0.579317 4 -0.272727 -0.220356 5 -0.0909091 0.355801 6 0.0909091 0.355801 7 0.272727 -0.220356 8 0.454545 0.579317 9 0.636364 -0.0743385 10 0.818182 0.309711 11 1 0.0498665 Sum(|W)|) = 3.17878 TEST02 Use a sequence of NCC 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.85914 0.140859 3 1.71886 0.000579323 4 1.71854 0.000258325 5 1.71828 8.59466e-07 6 1.71828 4.84531e-07 7 1.71828 1.05856e-09 8 1.71828 6.50492e-10 9 1.71828 1.50013e-11 10 1.71828 5.59703e-11 11 1.71828 2.44095e-10 12 1.71828 4.64967e-09 13 1.71828 1.13316e-08 14 1.71828 1.37356e-07 15 1.71828 8.53077e-07 16 1.71828 2.23641e-06 17 1.71825 2.68474e-05 18 1.71836 8.02021e-05 19 1.71663 0.00165085 20 1.70869 0.00959075 21 1.91569 0.197412 22 3.09691 1.37863 LINE_NCC_RULE_TEST Normal end of execution. 20 January 2020 01:01:48 PM