#! /usr/bin/env python # def ncc_set ( n ): #*****************************************************************************80 # ## NCC_SET sets abscissas and weights for closed Newton-Cotes quadrature. # # Discussion: # # The closed Newton-Cotes rules use equally spaced abscissas, and # hence may be used with tabulated function data. # # The rules are called "closed" because they include the endpoints. # As a favor, we include an order 1 rule, the midpoint rule, even # though this does not satisfy the requirement that the endpoints # be included. # # The higher order rules involve negative weights. These can produce # loss of accuracy due to the subtraction of large, nearly equal quantities. # # N 1 is the midpoint rule (and is not really an NCC rule.) # N 2 is the trapezoidal rule. # N 3 is Simpson's rule. # N 4 is Simpson's 3/8 rule. # N 5 is Bode's rule. # # The Kopal reference for N 12 lists # 15494566.0 / 43545600.0D+00 # but this results in a set of coeffients that don't add up to 2. # The correct value is # 15493566.0 / 43545600.0. # # The integral: # # Integral ( -1 <= X <= 1 ) F(X) dX # # The quadrature rule: # # Sum ( 1 <= I <= N ) (I) * F ( (I) ) # # In Mathematica, the Newton-Cotes closed weights # can be computed by: # # Needs["NumericalDifferentialEquationAnalysis`"] # NewtonCotesWeights [ n, -1, 1, QuadratureType -> Closed ] # # Licensing: # # This code is distributed under the GNU LGPL license. # # Modified: # # 08 June 2015 # # Author: # # John Burkardt # # Reference: # # Milton Abramowitz, Irene Stegun, # Handbook of Mathematical Functions, # National Bureau of Standards, 1964, # ISBN: 0-486-61272-4, # LC: QA47.A34. # # Johnson, # Quarterly Journal of Mathematics, # Volume 46, Number 52, 1915. # # Zdenek Kopal, # Numerical Analysis, # John Wiley, 1955, # LC: QA297.K6. # # Stephen Wolfram, # The Mathematica Book, # Fourth Edition, # Cambridge University Press, 1999, # ISBN: 0-521-64314-7, # LC: QA76.95.W65. # # Daniel Zwillinger, editor, # CRC Standard Mathematical Tables and Formulae, # 30th Edition, # CRC Press, 1996, # ISBN: 0-8493-2479-3, # LC: QA47.M315. # # Parameters: # # Input, integer N, the order. # N must be between 1 and 21. # # Output, real (N), the abscissas. # # Output, real (N), the weights. # from sys import exit import numpy as np if ( n == 1 ): # # 2 # x = np.array ( [ \ 0.00000000000000000000 ] ) w = np.array ( [ \ 2.00000000000000000000 ] ) elif ( n == 2 ): # # 1 # 1 # x = np.array ( [ \ -1.00000000000000000000, \ 1.00000000000000000000 ] ) w = np.array ( [ \ 1.00000000000000000000, \ 1.00000000000000000000 ] ) elif ( n == 3 ): # # 1 / 3 # 4 / 3 # 1 / 3 # x = np.array ( [ \ -1.00000000000000000000, \ 0.00000000000000000000, \ 1.00000000000000000000 ] ) w = np.array ( [ \ 0.33333333333333333333, \ 1.33333333333333333333, \ 0.33333333333333333333 ] ) elif ( n == 4 ): # # 1 / 4 # 3 / 4 # 3 / 4 # 1 / 4 # x = np.array ( [ \ -1.00000000000000000000, \ -0.33333333333333333333, \ 0.33333333333333333333, \ 1.00000000000000000000 ] ) w = np.array ( [ \ 0.25000000000000000000, \ 0.75000000000000000000, \ 0.75000000000000000000, \ 0.25000000000000000000 ] ) elif ( n == 5 ): # # 7 / 45 # 32 / 45 # 12 / 45 # 32 / 45 # 7 / 45 # x = np.array ( [ \ -1.00000000000000000000, \ -0.50000000000000000000, \ 0.00000000000000000000, \ 0.50000000000000000000, \ 1.00000000000000000000 ] ) w = np.array ( [ \ 0.15555555555555555556, \ 0.71111111111111111111, \ 0.26666666666666666667, \ 0.71111111111111111111, \ 0.15555555555555555556 ] ) elif ( n == 6 ): # # 19 / 144 # 75 / 144 # 50 / 144 # 50 / 144 # 75 / 144 # 19 / 144 # x = np.array ( [ \ -1.00000000000000000000, \ -0.60000000000000000000, \ -0.20000000000000000000, \ 0.20000000000000000000, \ 0.60000000000000000000, \ 1.00000000000000000000 ] ) w = np.array ( [ \ 0.13194444444444444444, \ 0.52083333333333333333, \ 0.34722222222222222222, \ 0.34722222222222222222, \ 0.52083333333333333333, \ 0.13194444444444444444 ] ) elif ( n == 7 ): # # 41 / 420 # 216 / 420 # 27 / 420 # 272 / 420 # 27 / 420 # 216 / 420 # 41 / 420 # x = np.array ( [ \ -1.00000000000000000000, \ -0.66666666666666666667, \ -0.33333333333333333333, \ 0.00000000000000000000, \ 0.33333333333333333333, \ 0.66666666666666666667, \ 1.00000000000000000000 ] ) w = np.array ( [ \ 0.097619047619047619048, \ 0.51428571428571428571, \ 0.064285714285714285714, \ 0.64761904761904761905, \ 0.064285714285714285714, \ 0.51428571428571428571, \ 0.097619047619047619048 ] ) elif ( n == 8 ): # # 751 / 8640 # 3577 / 8640 # 1323 / 8640 # 2989 / 8640 # 2989 / 8640 # 1323 / 8640 # 3577 / 8640 # 751 / 8640 # x = np.array ( [ \ -1.00000000000000000000, \ -0.71428571428571428571, \ -0.42857142857142857143, \ -0.14285714285714285714, \ 0.14285714285714285714, \ 0.42857142857142857143, \ 0.71428571428571428571, \ 1.00000000000000000000 ] ) w = np.array ( [ \ 0.086921296296296296296, \ 0.41400462962962962963, \ 0.15312500000000000000, \ 0.34594907407407407407, \ 0.34594907407407407407, \ 0.15312500000000000000, \ 0.41400462962962962963, \ 0.086921296296296296296 ] ) elif ( n == 9 ): # # 989 / 14175 # 5888 / 14175 # -928 / 14175 # 10496 / 14175 # -4540 / 14175 # 10496 / 14175 # -928 / 14175 # 5888 / 14175 # 989 / 14175 # x = np.array ( [ \ -1.00000000000000000000, \ -0.75000000000000000000, \ -0.50000000000000000000, \ -0.25000000000000000000, \ 0.00000000000000000000, \ 0.25000000000000000000, \ 0.50000000000000000000, \ 0.75000000000000000000, \ 1.00000000000000000000 ]) w = np.array ( [ \ 0.069770723104056437390, \ 0.41537918871252204586, \ -0.065467372134038800705, \ 0.74045855379188712522, \ -0.32028218694885361552, \ 0.74045855379188712522, \ -0.065467372134038800705, \ 0.41537918871252204586, \ 0.069770723104056437390 ] ) elif ( n == 10 ): # # 2857 / 44800 # 15741 / 44800 # 1080 / 44800 # 19344 / 44800 # 5778 / 44800 # 5778 / 44800 # 19344 / 44800 # 1080 / 44800 # 15741 / 44800 # 2857 / 44800 # x = np.array ( [ \ -1.00000000000000000000, \ -0.77777777777777777778, \ -0.55555555555555555556, \ -0.33333333333333333333, \ -0.11111111111111111111, \ 0.11111111111111111111, \ 0.33333333333333333333, \ 0.55555555555555555556, \ 0.77777777777777777778, \ 1.00000000000000000000 ] ) w = np.array ( [ \ 0.063772321428571428571, \ 0.35136160714285714286, \ 0.024107142857142857143, \ 0.43178571428571428571, \ 0.12897321428571428571, \ 0.12897321428571428571, \ 0.43178571428571428571, \ 0.024107142857142857143, \ 0.35136160714285714286, \ 0.063772321428571428571 ] ) elif ( n == 11 ): # # 16067 / 299376 # 106300 / 299376 # - 48525 / 299376 # 272400 / 299376 # - 260550 / 299376 # 427368 / 299376 # - 260550 / 299376 # 272400 / 299376 # - 48525 / 299376 # 106300 / 299376 # 16067 / 299376 # x = np.array ( [ \ -1.00000000000000000000, \ -0.80000000000000000000, \ -0.60000000000000000000, \ -0.40000000000000000000, \ -0.20000000000000000000, \ 0.00000000000000000000, \ 0.20000000000000000000, \ 0.40000000000000000000, \ 0.60000000000000000000, \ 0.80000000000000000000, \ 1.00000000000000000000 ] ) w = np.array ( [ \ 0.053668296723852279408, \ 0.35507188284966062744, \ -0.16208714125380792047, \ 0.90989257655924322591, \ -0.87031024531024531025, \ 1.4275292608625941959, \ -0.87031024531024531025, \ 0.90989257655924322591, \ -0.16208714125380792047, \ 0.35507188284966062744, \ 0.053668296723852279408 ] ) elif ( n == 12 ): # # 2171465 / 43545600 # 13486539 / 43545600 # - 3237113 / 43545600 # 25226685 / 43545600 # - 9595542 / 43545600 # 15493566 / 43545600 # 15493566 / 43545600 # - 9595542 / 43545600 # 25226685 / 43545600 # - 3237113 / 43545600 # 13486539 / 43545600 # 2171465 / 43545600 # x = np.array ( [ \ -1.00000000000000000000, \ -0.81818181818181818182, \ -0.63636363636363636364, \ -0.45454545454545454545, \ -0.27272727272727272727, \ -0.090909090909090909091, \ 0.090909090909090909091, \ 0.27272727272727272727, \ 0.45454545454545454545, \ 0.63636363636363636364, \ 0.81818181818181818182, \ 1.00000000000000000000 ] ) w = np.array ( [ \ 0.049866461823927101705, \ 0.30971071704144620811, \ -0.074338463587595532040, \ 0.57931650958994708995, \ -0.22035617835097001764, \ 0.35580095348324514991, \ 0.35580095348324514991, \ -0.22035617835097001764, \ 0.57931650958994708995, \ -0.074338463587595532040, \ 0.30971071704144620811, \ 0.049866461823927101705 ] ) elif ( n == 13 ): # # 1364651 / 31531500 # 9903168 / 31531500 # - 7587864 / 31531500 # 35725120 / 31531500 # - 51491295 / 31531500 # 87516288 / 31531500 # - 87797136 / 31531500 # 87516288 / 31531500 # - 51491295 / 31531500 # 35725120 / 31531500 # - 7587864 / 31531500 # 9903168 / 31531500 # 1364651 / 31531500 # x = np.array ( [ \ -1.00000000000000000000, \ -0.83333333333333333333, \ -0.66666666666666666667, \ -0.50000000000000000000, \ -0.33333333333333333333, \ -0.16666666666666666667, \ 0.00000000000000000000, \ 0.16666666666666666667, \ 0.33333333333333333333, \ 0.50000000000000000000, \ 0.66666666666666666667, \ 0.83333333333333333333, \ 1.00000000000000000000 ] ) w = np.array ( [ \ 0.043278974993260707546, \ 0.31407221350078492936, \ -0.24064392750107035821, \ 1.1329977958549387121, \ -1.6330112744398458684, \ 2.7755193378050520908, \ -2.7844262404262404262, \ 2.7755193378050520908, \ -1.6330112744398458684, \ 1.1329977958549387121, \ -0.24064392750107035821, \ 0.31407221350078492936, \ 0.043278974993260707546 ] ) elif ( n == 14 ): # # 6137698213 / 150885504000 # 42194238652 / 150885504000 # - 23361540993 / 150885504000 # 116778274403 / 150885504000 # - 113219777650 / 150885504000 # 154424590209 / 150885504000 # - 32067978834 / 150885504000 # - 32067978834 / 150885504000 # 154424590209 / 150885504000 # - 113219777650 / 150885504000 # 116778274403 / 150885504000 # - 23361540993 / 150885504000 # 42194238652 / 150885504000 # 6137698213 / 150885504000 # x = np.array ( [ \ -1.00000000000000000000, \ -0.84615384615384615385, \ -0.69230769230769230769, \ -0.53846153846153846154, \ -0.38461538461538461538, \ -0.23076923076923076923, \ -0.076923076923076923077, \ 0.076923076923076923077, \ 0.23076923076923076923, \ 0.38461538461538461538, \ 0.53846153846153846154, \ 0.69230769230769230769, \ 0.84615384615384615385, \ 1.00000000000000000000 ] ) w = np.array ( [ \ 0.040669438210247155353, \ 0.27975217053157074652, \ -0.15542374057682837445, \ 0.77579230848776566369, \ -0.75384763266423526013, \ 1.0273523591123107492, \ -0.21429490310083068020, \ -0.21429490310083068020, \ 1.0273523591123107492, \ -0.75384763266423526013, \ 0.77579230848776566369, \ -0.15542374057682837445, \ 0.27975217053157074652, \ 0.040669438210247155353 ] ) elif ( n == 15 ): # # 90241897 / 2501928000 # 710986864 / 2501928000 # - 770720657 / 2501928000 # 3501442784 / 2501928000 # - 6625093363 / 2501928000 # 12630121616 / 2501928000 # - 16802270373 / 2501928000 # 19534438464 / 2501928000 # - 16802270373 / 2501928000 # 12630121616 / 2501928000 # - 6625093363 / 2501928000 # 3501442784 / 2501928000 # - 770720657 / 2501928000 # 710986864 / 2501928000 # 90241897 / 2501928000 # x = np.array ( [ \ -1.00000000000000000000, \ -0.85714285714285714286, \ -0.71428571428571428571, \ -0.57142857142857142857, \ -0.42857142857142857143, \ -0.28571428571428571429, \ -0.14285714285714285714, \ 0.00000000000000000000, \ 0.14285714285714285714, \ 0.28571428571428571429, \ 0.42857142857142857143, \ 0.57142857142857142857, \ 0.71428571428571428571, \ 0.85714285714285714286, \ 1.00000000000000000000 ] ) w = np.array ( [ \ 0.036068942431596752584, \ 0.28417558938546592868, \ -0.30805069410470645039, \ 1.3994978208805369299, \ -2.6479952112930507992, \ 5.0481555088715582543, \ -6.7157289790113864188, \ 7.8077540456799716059, \ -6.7157289790113864188, \ 5.0481555088715582543, \ -2.6479952112930507992, \ 1.3994978208805369299, \ -0.30805069410470645039, \ 0.28417558938546592868, \ 0.036068942431596752584 ] ) elif ( n == 16 ): # # 105930069 / 3099672576 # 796661595 / 3099672576 # - 698808195 / 3099672576 # 3143332755 / 3099672576 # - 4688522055 / 3099672576 # 7385654007 / 3099672576 # - 6000998415 / 3099672576 # 3056422815 / 3099672576 # 3056422815 / 3099672576 # - 6000998415 / 3099672576 # 7385654007 / 3099672576 # - 4688522055 / 3099672576 # 3143332755 / 3099672576 # - 698808195 / 3099672576 # 796661595 / 3099672576 # 105930069 / 3099672576 # x = np.array ( [ \ -1.00000000000000000000, \ -0.86666666666666666667, \ -0.73333333333333333333, \ -0.60000000000000000000, \ -0.46666666666666666667, \ -0.33333333333333333333, \ -0.20000000000000000000, \ -0.066666666666666666667, \ 0.066666666666666666667, \ 0.20000000000000000000, \ 0.33333333333333333333, \ 0.46666666666666666667, \ 0.60000000000000000000, \ 0.73333333333333333333, \ 0.86666666666666666667, \ 1.00000000000000000000 ] ) w = np.array ( [ \ 0.034174599543251887002, \ 0.25701475735481036820, \ -0.22544581011901045383, \ 1.0140854164204471124, \ -1.5125862296882804695, \ 2.3827206990135980091, \ -1.9360104229924960952, \ 0.98604699046767964179, \ 0.98604699046767964179, \ -1.9360104229924960952, \ 2.3827206990135980091, \ -1.5125862296882804695, \ 1.0140854164204471124, \ -0.22544581011901045383, \ 0.25701475735481036820, \ 0.034174599543251887002 ] ) elif ( n == 17 ): # # 15043611773 / 488462349375 # 127626606592 / 488462349375 # - 179731134720 / 488462349375 # 832211855360 / 488462349375 # - 1929498607520 / 488462349375 # 4177588893696 / 488462349375 # - 6806534407936 / 488462349375 # 9368875018240 / 488462349375 # - 10234238972220 / 488462349375 # 9368875018240 / 488462349375 # - 6806534407936 / 488462349375 # 4177588893696 / 488462349375 # - 1929498607520 / 488462349375 # 832211855360 / 488462349375 # - 179731134720 / 488462349375 # 127626606592 / 488462349375 # 15043611773 / 488462349375 # x = np.array ( [ \ -1.00000000000000000000, \ -0.87500000000000000000, \ -0.75000000000000000000, \ -0.62500000000000000000, \ -0.50000000000000000000, \ -0.37500000000000000000, \ -0.25000000000000000000, \ -0.12500000000000000000, \ 0.00000000000000000000, \ 0.12500000000000000000, \ 0.25000000000000000000, \ 0.37500000000000000000, \ 0.50000000000000000000, \ 0.62500000000000000000, \ 0.75000000000000000000, \ 0.87500000000000000000, \ 1.00000000000000000000 ] ) w = np.array ( [ \ 0.030797894233299012495, \ 0.26128238288028031086, \ -0.36795289329867605622, \ 1.7037379778090086905, \ -3.9501480717783930427, \ 8.5525299934402953388, \ -13.934614237197880038, \ 19.180342211078732848, \ -20.951950514333334128, \ 19.180342211078732848, \ -13.934614237197880038, \ 8.5525299934402953388, \ -3.9501480717783930427, \ 1.7037379778090086905, \ -0.36795289329867605622, \ 0.26128238288028031086, \ 0.030797894233299012495 ] ) elif ( n == 18 ): # # 55294720874657 / 1883051089920000 # 450185515446285 / 1883051089920000 # - 542023437008852 / 1883051089920000 # 2428636525764260 / 1883051089920000 # - 4768916800123440 / 1883051089920000 # 8855416648684984 / 1883051089920000 # - 10905371859796660 / 1883051089920000 # 10069615750132836 / 1883051089920000 # - 3759785974054070 / 1883051089920000 # - 3759785974054070 / 1883051089920000 # 10069615750132836 / 1883051089920000 # - 10905371859796660 / 1883051089920000 # 8855416648684984 / 1883051089920000 # - 4768916800123440 / 1883051089920000 # 2428636525764260 / 1883051089920000 # - 542023437008852 / 1883051089920000 # 450185515446285 / 1883051089920000 # 55294720874657 / 1883051089920000 # x = np.array ( [ \ -1.00000000000000000000, \ -0.88235294117647058824, \ -0.76470588235294117647, \ -0.64705882352941176471, \ -0.52941176470588235294, \ -0.41176470588235294118, \ -0.29411764705882352941, \ -0.17647058823529411765, \ -0.058823529411764705882, \ 0.058823529411764705882, \ 0.17647058823529411765, \ 0.29411764705882352941, \ 0.41176470588235294118, \ 0.52941176470588235294, \ 0.64705882352941176471, \ 0.76470588235294117647, \ 0.88235294117647058824, \ 1.00000000000000000000 ] ) w = np.array ( [ \ 0.029364429446790078519, \ 0.23907238516051669677, \ -0.28784319231183443641, \ 1.2897348026109258587, \ -2.5325477495812627261, \ 4.7026959045817496499, \ -5.7913308450170443690, \ 5.3475000248456540826, \ -1.9966457597354948350, \ -1.9966457597354948350, \ 5.3475000248456540826, \ -5.7913308450170443690, \ 4.7026959045817496499, \ -2.5325477495812627261, \ 1.2897348026109258587, \ -0.28784319231183443641, \ 0.23907238516051669677, \ 0.029364429446790078519 ] ) elif ( n == 19 ): # # 203732352169 / 7604556960000 # 1848730221900 / 7604556960000 # - 3212744374395 / 7604556960000 # 15529830312096 / 7604556960000 # - 42368630685840 / 7604556960000 # 103680563465808 / 7604556960000 # - 198648429867720 / 7604556960000 # 319035784479840 / 7604556960000 # - 419127951114198 / 7604556960000 # 461327344340680 / 7604556960000 # - 419127951114198 / 7604556960000 # 319035784479840 / 7604556960000 # - 198648429867720 / 7604556960000 # 103680563465808 / 7604556960000 # - 42368630685840 / 7604556960000 # 15529830312096 / 7604556960000 # - 3212744374395 / 7604556960000 # 1848730221900 / 7604556960000 # 203732352169 / 7604556960000 # x = np.array ( [ \ -1.00000000000000000000, \ -0.88888888888888888889, \ -0.77777777777777777778, \ -0.66666666666666666667, \ -0.55555555555555555556, \ -0.44444444444444444444, \ -0.33333333333333333333, \ -0.22222222222222222222, \ -0.11111111111111111111, \ 0.00000000000000000000, \ 0.11111111111111111111, \ 0.22222222222222222222, \ 0.33333333333333333333, \ 0.44444444444444444444, \ 0.55555555555555555556, \ 0.66666666666666666667, \ 0.77777777777777777778, \ 0.88888888888888888889, \ 1.00000000000000000000 ] ) w = np.array ( [ \ 0.026790824664820447344, \ 0.24310820888374278151, \ -0.42247620621346493274, \ 2.0421742376029227612, \ -5.5714791681749728126, \ 13.634004454324976218, \ -26.122288374274995239, \ 41.953237533490708445, \ -55.115367445968607749, \ 60.664591871329740161, \ -55.115367445968607749, \ 41.953237533490708445, \ -26.122288374274995239, \ 13.634004454324976218, \ -5.5714791681749728126, \ 2.0421742376029227612, \ -0.42247620621346493274, \ 0.24310820888374278151, \ 0.026790824664820447344 ] ) elif ( n == 20 ): # # 69028763155644023 / 2688996956405760000 # 603652082270808125 / 2688996956405760000 # - 926840515700222955 / 2688996956405760000 # 4301581538450500095 / 2688996956405760000 # - 10343692234243192788 / 2688996956405760000 # 22336420328479961316 / 2688996956405760000 # - 35331888421114781580 / 2688996956405760000 # 43920768370565135580 / 2688996956405760000 # - 37088370261379851390 / 2688996956405760000 # 15148337305921759574 / 2688996956405760000 # 15148337305921759574 / 2688996956405760000 # - 37088370261379851390 / 2688996956405760000 # 43920768370565135580 / 2688996956405760000 # - 35331888421114781580 / 2688996956405760000 # 22336420328479961316 / 2688996956405760000 # - 10343692234243192788 / 2688996956405760000 # 4301581538450500095 / 2688996956405760000 # - 926840515700222955 / 2688996956405760000 # 603652082270808125 / 2688996956405760000 # 69028763155644023 / 2688996956405760000 # x = np.array ( [ \ -1.00000000000000000000, \ -0.89473684210526315789, \ -0.78947368421052631579, \ -0.68421052631578947368, \ -0.57894736842105263158, \ -0.47368421052631578947, \ -0.36842105263157894737, \ -0.26315789473684210526, \ -0.15789473684210526316, \ -0.052631578947368421053, \ 0.052631578947368421053, \ 0.15789473684210526316, \ 0.26315789473684210526, \ 0.36842105263157894737, \ 0.47368421052631578947, \ 0.57894736842105263158, \ 0.68421052631578947368, \ 0.78947368421052631579, \ 0.89473684210526315789, \ 1.00000000000000000000 ] ) w = np.array ( [ \ 0.025670822345560078100, \ 0.22448968595251886556, \ -0.34467890099030890987, \ 1.5996974366978074270, \ -3.8466730910952978835, \ 8.3065993344729824120, \ -13.139430424771119113, \ 16.333513604742678295, \ -13.792641220001198577, \ 5.6334527526463774045, \ 5.6334527526463774045, \ -13.792641220001198577, \ 16.333513604742678295, \ -13.139430424771119113, \ 8.3065993344729824120, \ -3.8466730910952978835, \ 1.5996974366978074270, \ -0.34467890099030890987, \ 0.22448968595251886556, \ 0.025670822345560078100 ] ) elif ( n == 21 ): x = np.array ( [ \ -1.00000000000000000000, \ -0.90000000000000000000, \ -0.80000000000000000000, \ -0.70000000000000000000, \ -0.60000000000000000000, \ -0.50000000000000000000, \ -0.40000000000000000000, \ -0.30000000000000000000, \ -0.20000000000000000000, \ -0.10000000000000000000, \ 0.00000000000000000000, \ 0.10000000000000000000, \ 0.20000000000000000000, \ 0.30000000000000000000, \ 0.40000000000000000000, \ 0.50000000000000000000, \ 0.60000000000000000000, \ 0.70000000000000000000, \ 0.80000000000000000000, \ 0.90000000000000000000, \ 1.00000000000000000000 ] ) w = np.array ( [ \ 0.023650546498063206389, \ 0.22827543528921394997, \ -0.47295674102285392846, \ 2.4123737869637513288, \ -7.5420634534306609355, \ 20.673596439879602287, \ -45.417631687959024596, \ 83.656114844387109207, \ -128.15055898030800930, \ 165.59456694494570344, \ -180.01073427048578932, \ 165.59456694494570344, \ -128.15055898030800930, \ 83.656114844387109207, \ -45.417631687959024596, \ 20.673596439879602287, \ -7.5420634534306609355, \ 2.4123737869637513288, \ -0.47295674102285392846, \ 0.22827543528921394997, \ 0.023650546498063206389 ] ) else: print ( '' ) print ( 'NCC_SET - Fatal error!' ) print ( ' Illegal value of N %d' % ( n ) ) print ( ' Legal values are 1 through 21.' ) exit ( 'NCC_SET - Fatal error!' ) return x, w def ncc_set_test ( ): #*****************************************************************************80 # ## NCC_SET_TEST tests NCC_SET. # # Licensing: # # This code is distributed under the GNU LGPL license. # # Modified: # # 08 June 2015 # # Author: # # John Burkardt # import platform print ( '' ) print ( 'NCC_SET_TEST' ) print ( ' Python version: %s' % ( platform.python_version ( ) ) ) print ( ' NCC_SET sets up a Newton-Cotes Closed quadrature rule' ) print ( '' ) print ( ' Index X W' ) for n in range ( 1, 11 ): x, w = ncc_set ( n ) print ( '' ) for i in range ( 0, n ): print ( ' %2d %12g %12g' % ( i, x[i], w[i] ) ) # # Terminate. # print ( '' ) print ( 'NCC_SET_TEST:' ) print ( ' Normal end of execution.' ) return if ( __name__ == '__main__' ): from timestamp import timestamp timestamp ( ) ncc_set_test ( ) timestamp ( )