18 October 2014 10:04:03 AM LEGENDRE_POLYNOMIAL_PRB: C++ version. Test the LEGENDRE_POLYNOMIAL library. LEGENDRE_POLYNOMIAL_TEST01: P_POLYNOMIAL_VALUES stores values of the Legendre polynomial P(n,x). P_POLYNOMIAL_VALUE evaluates the polynomial. Tabulated Computed N X P(N,X) P(N,X) Error 0 0.25 1 1 0 1 0.25 0.25 0.25 0 2 0.25 -0.40625 -0.40625 0 3 0.25 -0.3359375 -0.3359375 0 4 0.25 0.15771484375 0.15771484375 0 5 0.25 0.3397216796875 0.3397216796875 0 6 0.25 0.0242767333984375 0.0242767333984375 0 7 0.25 -0.2799186706542969 -0.2799186706542969 0 8 0.25 -0.1524540185928345 -0.1524540185928345 -2.775557561562891e-17 9 0.25 0.1768244206905365 0.1768244206905365 0 10 0.25 0.2212002165615559 0.2212002165615559 2.775557561562891e-17 3 0 0 -0 0 3 0.1 -0.1475 -0.1475 0 3 0.2 -0.28 -0.28 0 3 0.3 -0.3825 -0.3825 0 3 0.4 -0.44 -0.4399999999999999 -5.551115123125783e-17 3 0.5 -0.4375 -0.4375 0 3 0.6 -0.36 -0.36 5.551115123125783e-17 3 0.7 -0.1925 -0.1925000000000001 1.110223024625157e-16 3 0.8 0.08 0.08000000000000022 -2.220446049250313e-16 3 0.9 0.4725 0.4725000000000001 -1.110223024625157e-16 3 1 1 1 0 LEGENDRE_POLYNOMIAL_TEST015: P_POLYNOMIAL_PRIME evaluates the derivative of the Legendre polynomial P(n,x). Computed N X P'(N,X) 0 -1 0 1 -1 1 2 -1 -3 3 -1 6 4 -1 -10 5 -1 15 0 -0.8 0 1 -0.8 1 2 -0.8 -2.4 3 -0.8 3.300000000000001 4 -0.8 -2.960000000000001 5 -0.8 1.203000000000002 0 -0.6 0 1 -0.6 1 2 -0.6 -1.8 3 -0.6 1.199999999999999 4 -0.6 0.7200000000000008 5 -0.6 -2.472 0 -0.4 0 1 -0.4 1 2 -0.4 -1.2 3 -0.4 -0.2999999999999998 4 -0.4 1.88 5 -0.4 -1.317 0 -0.2 0 1 -0.2 1 2 -0.2 -0.6000000000000001 3 -0.2 -1.2 4 -0.2 1.36 5 -0.2 0.8879999999999999 0 0 0 1 0 1 2 0 0 3 0 -1.5 4 0 -0 5 0 1.875 0 0.2 0 1 0.2 1 2 0.2 0.6000000000000001 3 0.2 -1.2 4 0.2 -1.36 5 0.2 0.8879999999999999 0 0.4 0 1 0.4 1 2 0.4 1.2 3 0.4 -0.2999999999999998 4 0.4 -1.88 5 0.4 -1.317 0 0.6 0 1 0.6 1 2 0.6 1.8 3 0.6 1.199999999999999 4 0.6 -0.7200000000000008 5 0.6 -2.472 0 0.8 0 1 0.8 1 2 0.8 2.4 3 0.8 3.300000000000001 4 0.8 2.960000000000001 5 0.8 1.203000000000002 0 1 0 1 1 1 2 1 3 3 1 6 4 1 10 5 1 15 LEGENDRE_POLYNOMIAL_TEST016: P_POLYNOMIAL_PRIME2 evaluates the second derivative of the Legendre polynomial P(n,x). Computed N X P"(N,X) 0 -1 0 1 -1 0 2 -1 3 3 -1 -15 4 -1 45 5 -1 -105 0 -0.8 0 1 -0.8 0 2 -0.8 3 3 -0.8 -12 4 -0.8 26.1 5 -0.8 -38.64000000000001 0 -0.6 0 1 -0.6 0 2 -0.6 3 3 -0.6 -8.999999999999998 4 -0.6 11.4 5 -0.6 -2.519999999999995 0 -0.4 0 1 -0.4 0 2 -0.4 3 3 -0.4 -6.000000000000001 4 -0.4 0.9000000000000012 5 -0.4 10.92 0 -0.2 0 1 -0.2 0 2 -0.2 3 3 -0.2 -3 4 -0.2 -5.399999999999999 5 -0.2 9.239999999999998 0 0 0 1 0 0 2 0 3 3 0 0 4 0 -7.5 5 0 -0 0 0.2 0 1 0.2 0 2 0.2 3 3 0.2 3 4 0.2 -5.399999999999999 5 0.2 -9.239999999999998 0 0.4 0 1 0.4 0 2 0.4 3 3 0.4 6.000000000000001 4 0.4 0.9000000000000012 5 0.4 -10.92 0 0.6 0 1 0.6 0 2 0.6 3 3 0.6 8.999999999999998 4 0.6 11.4 5 0.6 2.519999999999995 0 0.8 0 1 0.8 0 2 0.8 3 3 0.8 12 4 0.8 26.1 5 0.8 38.64000000000001 0 1 0 1 1 0 2 1 3 3 1 15 4 1 45 5 1 105 LEGENDRE_POLYNOMIAL_TEST02 P_POLYNOMIAL_COEFFICIENTS: coefficients of Legendre polynomial P(n,x). P(0,x) = 1 P(1,x) = 1 * x P(2,x) = 1.5 * x^2 -0.5 P(3,x) = 2.5 * x^3 -1.5 * x P(4,x) = 4.375 * x^4 -3.75 * x^2 0.375 P(5,x) = 7.875 * x^5 -8.75 * x^3 1.875 * x P(6,x) = 14.4375 * x^6 -19.6875 * x^4 6.5625 * x^2 -0.3125 P(7,x) = 26.8125 * x^7 -43.3125 * x^5 19.6875 * x^3 -2.1875 * x P(8,x) = 50.2734 * x^8 -93.8438 * x^6 54.1406 * x^4 -9.84375 * x^2 0.273438 P(9,x) = 94.9609 * x^9 -201.094 * x^7 140.766 * x^5 -36.0938 * x^3 2.46094 * x P(10,x) = 180.426 * x^10 -427.324 * x^8 351.914 * x^6 -117.305 * x^4 13.5352 * x^2 -0.246094 LEGENDRE_POLYNOMIAL_TEST03: P_POLYNOMIAL_ZEROS computes the zeros of P(n,x) Check by calling P_POLYNOMIAL_VALUE there. Computed zeros for P(1,z): 0: 0 Evaluate P(1,z): 0: 0 Computed zeros for P(2,z): 0: -0.57735 1: 0.57735 Evaluate P(2,z): 0: -2.77556e-16 1: -2.77556e-16 Computed zeros for P(3,z): 0: -0.774597 1: 1.99493e-17 2: 0.774597 Evaluate P(3,z): 0: 2.22045e-16 1: -2.9924e-17 2: -6.66134e-16 Computed zeros for P(4,z): 0: -0.861136 1: -0.339981 2: 0.339981 3: 0.861136 Evaluate P(4,z): 0: 5.55112e-16 1: 5.55112e-17 2: 5.55112e-17 3: -1.66533e-16 Computed zeros for P(5,z): 0: -0.90618 1: -0.538469 2: -1.08185e-16 3: 0.538469 4: 0.90618 Evaluate P(5,z): 0: -9.76996e-16 1: -3.10862e-16 2: -2.02848e-16 3: -4.44089e-17 4: -1.06581e-15 LEGENDRE_POLYNOMIAL_TEST04: P_QUADRATURE_RULE computes the quadrature rule associated with P(n,x) X W 0: -0.949108 0.129485 1: -0.741531 0.279705 2: -0.405845 0.38183 3: 2.94435e-16 0.417959 4: 0.405845 0.38183 5: 0.741531 0.279705 6: 0.949108 0.129485 Use the quadrature rule to estimate: Q = Integral ( -1 <= X <= +1.0 ) X^E dx E Q_Estimate Q_Exact 0 2 2 1 9.15934e-16 0 2 0.666667 0.666667 3 4.30211e-16 0 4 0.4 0.4 5 2.08167e-16 0 6 0.285714 0.285714 7 9.71445e-17 0 8 0.222222 0.222222 9 4.16334e-17 0 10 0.181818 0.181818 11 -2.77556e-17 0 12 0.153846 0.153846 13 -6.93889e-17 0 LEGENDRE_POLYNOMIAL_TEST05 Compute a Legendre exponential product table. Tij = integral ( -1.0 <= X <= +1.0 ) exp(B*X) P(I,X) P(J,X) dx where P(I,X) = Legendre polynomial of degree I. Maximum degree P = 5 Exponential argument coefficient B = 0 Exponential product table: Col: 0 1 2 3 4 Row 0: 2 3.33067e-16 7.35523e-16 1.80411e-16 -7.91034e-16 1: 3.33067e-16 0.666667 2.08167e-16 -1.249e-16 -8.18789e-16 2: 7.35523e-16 2.08167e-16 0.4 -6.45317e-16 -9.71445e-17 3: 1.80411e-16 -1.249e-16 -6.38378e-16 0.285714 -2.22045e-16 4: -7.91034e-16 -8.11851e-16 -1.249e-16 -2.15106e-16 0.222222 5: -1.65146e-15 -5.13478e-16 -2.91434e-16 -3.81639e-16 -6.93889e-18 Col: 5 Row 0: -1.65146e-15 1: -5.06539e-16 2: -2.91434e-16 3: -3.747e-16 4: -6.93889e-18 5: 0.181818 LEGENDRE_POLYNOMIAL_TEST05 Compute a Legendre exponential product table. Tij = integral ( -1.0 <= X <= +1.0 ) exp(B*X) P(I,X) P(J,X) dx where P(I,X) = Legendre polynomial of degree I. Maximum degree P = 5 Exponential argument coefficient B = 1 Exponential product table: Col: 0 1 2 3 4 Row 0: 2.3504 0.735759 0.143126 0.0201302 0.00221447 1: 0.735759 0.878885 0.306382 0.062605 0.00905782 2: 0.143126 0.306382 0.512112 0.194658 0.0414752 3: 0.0201302 0.062605 0.194658 0.363558 0.143849 4: 0.00221447 0.00905782 0.0414752 0.143849 0.28217 5: 0.000199925 0.00101492 0.00615177 0.0313811 0.114325 Col: 5 Row 0: 0.000199925 1: 0.00101492 2: 0.00615177 3: 0.0313811 4: 0.114325 5: 0.230635 LEGENDRE_POLYNOMIAL_TEST06 Compute a Legendre power product table. Tij = integral ( -1.0 <= X <= +1.0 ) X^E P(I,X) P(J,X) dx where P(I,X) = Legendre polynomial of degree I. Maximum degree P = 5 Exponent of X, E = 0 Power product table: Col: 0 1 2 3 4 Row 0: 2 3.05311e-16 9.71445e-16 1.38778e-16 5.68989e-16 1: 3.05311e-16 0.666667 1.66533e-16 7.21645e-16 2.35922e-16 2: 9.71445e-16 1.66533e-16 0.4 2.35922e-16 3.60822e-16 3: 1.38778e-16 7.49401e-16 2.22045e-16 0.285714 2.77556e-17 4: 5.68989e-16 2.35922e-16 3.747e-16 1.38778e-17 0.222222 5: 3.19189e-16 2.01228e-16 0 2.67147e-16 4.33681e-17 Col: 5 Row 0: 3.19189e-16 1: 1.80411e-16 2: 3.46945e-18 3: 2.60209e-16 4: 5.0307e-17 5: 0.181818 LEGENDRE_POLYNOMIAL_TEST06 Compute a Legendre power product table. Tij = integral ( -1.0 <= X <= +1.0 ) X^E P(I,X) P(J,X) dx where P(I,X) = Legendre polynomial of degree I. Maximum degree P = 5 Exponent of X, E = 1 Power product table: Col: 0 1 2 3 4 Row 0: 9.15934e-16 0.666667 2.08167e-16 -3.60822e-16 -3.46945e-16 1: 0.666667 4.30211e-16 0.266667 -1.38778e-16 -3.747e-16 2: 2.08167e-16 0.266667 1.38778e-17 0.171429 -2.77556e-16 3: -3.60822e-16 -1.38778e-16 0.171429 -1.66533e-16 0.126984 4: -3.46945e-16 -3.747e-16 -2.63678e-16 0.126984 -1.38778e-17 5: -3.95517e-16 -4.23273e-16 -3.26128e-16 -9.71445e-17 0.10101 Col: 5 Row 0: -3.95517e-16 1: -4.3715e-16 2: -3.26128e-16 3: -1.04083e-16 4: 0.10101 5: 2.77556e-17 LEGENDRE_POLYNOMIAL_TEST07: PM_POLYNOMIAL_VALUES stores values of the Legendre polynomial Pm(n,m,x). PM_POLYNOMIAL_VALUE evaluates the polynomial. Tabulated Computed N M X Pm(N,M,X) Pm(N,M,X) Error 1 0 0 0 0 0 2 0 0 -0.5 -0.5 0 3 0 0 0 -0 0 4 0 0 0.375 0.375 0 5 0 0 0 0 0 1 1 0.5 -0.8660254037844386 -0.8660254037844386 0 2 1 0.5 -1.299038105676658 -1.299038105676658 0 3 1 0.5 -0.3247595264191645 -0.3247595264191645 0 4 1 0.5 1.353164693413185 1.353164693413185 -4.440892098500626e-16 3 0 0.2 -0.28 -0.28 0 3 1 0.2 1.175755076535925 1.175755076535925 -4.440892098500626e-16 3 2 0.2 2.88 2.88 0 3 3 0.2 -14.10906091843111 -14.1090609184311 -7.105427357601002e-15 4 2 0.25 -3.955078125 -3.955078125 4.440892098500626e-16 5 2 0.25 -9.99755859375 -9.997558593750002 1.77635683940025e-15 6 3 0.25 82.65311444100485 82.65311444100486 -1.4210854715202e-14 7 3 0.25 20.24442836815152 20.24442836815153 -1.06581410364015e-14 8 4 0.25 -423.7997531890869 -423.7997531890869 -5.684341886080801e-14 9 4 0.25 1638.320624828339 1638.320624828339 0 10 5 0.25 -20256.87389227225 -20256.87389227226 3.637978807091713e-12 LEGENDRE_POLYNOMIAL_TEST08: PMN_POLYNOMIAL_VALUES stores values of the normalized Legendre polynomial Pmn(n,m,x). PMN_POLYNOMIAL_VALUE evaluates the polynomial. Tabulated Computed N M X Pmn(N,M,X) Pmn(N,M,X) Error 0 0 0.5 0.7071067811865475 0.7071067811865476 -1.110223024625157e-16 1 0 0.5 0.6123724356957945 0.6123724356957945 0 1 1 0.5 -0.75 -0.7499999999999999 -1.110223024625157e-16 2 0 0.5 -0.1976423537605237 -0.1976423537605237 2.775557561562891e-17 2 1 0.5 -0.8385254915624211 -0.8385254915624212 1.110223024625157e-16 2 2 0.5 0.7261843774138907 0.7261843774138906 1.110223024625157e-16 3 0 0.5 -0.8184875533567997 -0.8184875533567997 0 3 1 0.5 -0.1753901900050285 -0.1753901900050285 2.775557561562891e-17 3 2 0.5 0.9606516343087123 0.9606516343087123 0 3 3 0.5 -0.6792832849776299 -0.67928328497763 1.110223024625157e-16 4 0 0.5 -0.6131941618102092 -0.6131941618102091 -1.110223024625157e-16 4 1 0.5 0.6418623720763665 0.6418623720763665 0 4 2 0.5 0.4716705890038619 0.4716705890038619 0 4 3 0.5 -1.018924927466445 -1.018924927466445 0 4 4 0.5 0.6239615396237876 0.6239615396237875 1.110223024625157e-16 5 0 0.5 0.2107022704608181 0.2107022704608181 -2.775557561562891e-17 5 1 0.5 0.8256314721961969 0.8256314721961968 1.110223024625157e-16 5 2 0.5 -0.3982651281554632 -0.3982651281554632 -5.551115123125783e-17 5 3 0.5 -0.7040399320721435 -0.7040399320721434 -1.110223024625157e-16 5 4 0.5 1.034723155272289 1.034723155272289 4.440892098500626e-16 5 5 0.5 -0.566741212915553 -0.566741212915553 0 LEGENDRE_POLYNOMIAL_TEST09: PMNS_POLYNOMIAL_VALUES stores values of the sphere-normalized Legendre polynomial Pmns(n,m,x). PMNS_POLYNOMIAL_VALUE evaluates the polynomial. Tabulated Computed N M X Pmns(N,M,X) Pmns(N,M,X) Error 0 0 0.5 0.2820947917738781 0.2820947917738781 -5.551115123125783e-17 1 0 0.5 0.24430125595146 0.24430125595146 2.775557561562891e-17 1 1 0.5 -0.2992067103010745 -0.2992067103010745 0 2 0 0.5 -0.07884789131313 -0.07884789131313001 1.387778780781446e-17 2 1 0.5 -0.3345232717786446 -0.3345232717786445 -5.551115123125783e-17 2 2 0.5 0.2897056515173922 0.2897056515173921 5.551115123125783e-17 3 0 0.5 -0.326529291016351 -0.326529291016351 0 3 1 0.5 -0.06997056236064664 -0.06997056236064664 0 3 2 0.5 0.3832445536624809 0.3832445536624809 -5.551115123125783e-17 3 3 0.5 -0.2709948227475519 -0.2709948227475519 5.551115123125783e-17 4 0 0.5 -0.24462907724141 -0.24462907724141 -2.775557561562891e-17 4 1 0.5 0.2560660384200185 0.2560660384200185 0 4 2 0.5 0.1881693403754876 0.1881693403754876 2.775557561562891e-17 4 3 0.5 -0.4064922341213279 -0.406492234121328 5.551115123125783e-17 4 4 0.5 0.2489246395003027 0.2489246395003027 -5.551115123125783e-17 5 0 0.5 0.0840580442633982 0.08405804426339822 -1.387778780781446e-17 5 1 0.5 0.3293793022891428 0.3293793022891428 0 5 2 0.5 -0.1588847984307093 -0.1588847984307093 2.775557561562891e-17 5 3 0.5 -0.2808712959945307 -0.2808712959945307 0 5 4 0.5 0.4127948151484925 0.4127948151484925 0 5 5 0.5 -0.2260970318780046 -0.2260970318780046 2.775557561562891e-17 LEGENDRE_POLYNOMIAL_TEST095 PN_POLYNOMIAL_COEFFICIENTS: coefficients of normalized Legendre polynomial P(n,x). P(0,x) = 0.707107 P(1,x) = 1.22474 * x P(2,x) = 2.37171 * x^2 -0.790569 P(3,x) = 4.67707 * x^3 -2.80624 * x P(4,x) = 9.28078 * x^4 -7.95495 * x^2 0.795495 P(5,x) = 18.4685 * x^5 -20.5206 * x^3 4.39726 * x P(6,x) = 36.8085 * x^6 -50.1935 * x^4 16.7312 * x^2 -0.796722 P(7,x) = 73.4291 * x^7 -118.616 * x^5 53.9164 * x^3 -5.99072 * x P(8,x) = 146.571 * x^8 -273.599 * x^6 157.846 * x^4 -28.6992 * x^2 0.7972 P(9,x) = 292.689 * x^9 -619.813 * x^7 433.869 * x^5 -111.248 * x^3 7.58512 * x P(10,x) = 584.646 * x^10 -1384.69 * x^8 1140.33 * x^6 -380.111 * x^4 43.8589 * x^2 -0.797435 LEGENDRE_POLYNOMIAL_TEST10 Compute a pair product table for Pn(n,x). Tij = integral ( -1.0 <= X <= +1.0 ) Pn(I,X) Pn(J,X) dx where Pn(I,X) = normalized Legendre polynomial of degree I. Maximum degree P = 5 Pair product table: Col: 0 1 2 3 4 Row 0: 1 2.77556e-16 9.99201e-16 1.66533e-16 8.74301e-16 1: 2.498e-16 1 3.33067e-16 1.7486e-15 6.66134e-16 2: 1.02696e-15 3.05311e-16 1 6.66134e-16 1.19349e-15 3: 1.94289e-16 1.69309e-15 7.77156e-16 1 2.77556e-17 4: 8.88178e-16 6.66134e-16 1.22125e-15 2.77556e-17 1 5: 5.41234e-16 5.55112e-16 0 1.16573e-15 1.94289e-16 Col: 5 Row 0: 5.13478e-16 1: 6.38378e-16 2: 2.77556e-17 3: 1.16573e-15 4: 1.94289e-16 5: 1 LEGENDRE_POLYNOMIAL_PRB: Normal end of execution. 18 October 2014 10:04:03 AM