07-Jan-2022 22:47:04 legendre_polynomial_test(): MATLAB/Octave version 9.8.0.1380330 (R2020a) Update 2 Test legendre_polynomial(). P_EXPONENTIAL_PRODUCT_TEST P_EXPONENTIAL_PRODUCT computes an exponential product table for P(n,x): Tij = integral ( -1 <= x <= +1 ) exp(b*x) P(i,x) P(j,x) dx Maximum degree P = 5 Exponential argument coefficient B = 0 Exponential product table: Col: 1 2 3 4 5 Row 1 : 2 3.33067e-16 7.35523e-16 1.80411e-16 -7.91034e-16 2 : 3.33067e-16 0.666667 2.08167e-16 -1.249e-16 -8.18789e-16 3 : 7.35523e-16 2.08167e-16 0.4 -6.45317e-16 -9.71445e-17 4 : 1.80411e-16 -1.249e-16 -6.38378e-16 0.285714 -2.22045e-16 5 :-7.91034e-16 -8.11851e-16 -1.249e-16 -2.15106e-16 0.222222 6 :-1.65146e-15 -5.13478e-16 -2.91434e-16 -3.81639e-16 -6.93889e-18 Col: 6 Row 1 :-1.65146e-15 2 :-5.06539e-16 3 :-2.91434e-16 4 : -3.747e-16 5 :-6.93889e-18 6 : 0.181818 P_EXPONENTIAL_PRODUCT_TEST P_EXPONENTIAL_PRODUCT computes an exponential product table for P(n,x): Tij = integral ( -1 <= x <= +1 ) exp(b*x) P(i,x) P(j,x) dx Maximum degree P = 5 Exponential argument coefficient B = 1 Exponential product table: Col: 1 2 3 4 5 Row 1 : 2.3504 0.735759 0.143126 0.0201302 0.00221447 2 : 0.735759 0.878885 0.306382 0.062605 0.00905782 3 : 0.143126 0.306382 0.512112 0.194658 0.0414752 4 : 0.0201302 0.062605 0.194658 0.363558 0.143849 5 : 0.00221447 0.00905782 0.0414752 0.143849 0.28217 6 : 0.000199925 0.00101492 0.00615177 0.0313811 0.114325 Col: 6 Row 1 : 0.000199925 2 : 0.00101492 3 : 0.00615177 4 : 0.0313811 5 : 0.114325 6 : 0.230635 P_POLYNOMIAL_COEFFICIENTS_TEST P_POLYNOMIAL_COEFFICIENTS determines polynomial coefficients of 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 P_POLYNOMIAL_PLOT_TEST: P_POLYNOMIAL_PLOT creates a plot of one or more Legendre functions. Legendre polynomial plot stored in file "p_polynomial_plot.png". P_POLYNOMIAL_PRIME_TEST: P_POLYNOMIAL_PRIME evaluates the derivative of the Legendre polynomial P(N,X). Computed N X P'(N,X) 0 -1.000000 0 1 -1.000000 1 2 -1.000000 -3 3 -1.000000 6 4 -1.000000 -10 5 -1.000000 15 0 -0.800000 0 1 -0.800000 1 2 -0.800000 -2.4 3 -0.800000 3.3 4 -0.800000 -2.96 5 -0.800000 1.203 0 -0.600000 0 1 -0.600000 1 2 -0.600000 -1.8 3 -0.600000 1.2 4 -0.600000 0.72 5 -0.600000 -2.472 0 -0.400000 0 1 -0.400000 1 2 -0.400000 -1.2 3 -0.400000 -0.3 4 -0.400000 1.88 5 -0.400000 -1.317 0 -0.200000 0 1 -0.200000 1 2 -0.200000 -0.6 3 -0.200000 -1.2 4 -0.200000 1.36 5 -0.200000 0.888 0 0.000000 0 1 0.000000 1 2 0.000000 0 3 0.000000 -1.5 4 0.000000 -0 5 0.000000 1.875 0 0.200000 0 1 0.200000 1 2 0.200000 0.6 3 0.200000 -1.2 4 0.200000 -1.36 5 0.200000 0.888 0 0.400000 0 1 0.400000 1 2 0.400000 1.2 3 0.400000 -0.3 4 0.400000 -1.88 5 0.400000 -1.317 0 0.600000 0 1 0.600000 1 2 0.600000 1.8 3 0.600000 1.2 4 0.600000 -0.72 5 0.600000 -2.472 0 0.800000 0 1 0.800000 1 2 0.800000 2.4 3 0.800000 3.3 4 0.800000 2.96 5 0.800000 1.203 0 1.000000 0 1 1.000000 1 2 1.000000 3 3 1.000000 6 4 1.000000 10 5 1.000000 15 P_POLYNOMIAL_PRIME2_TEST: P_POLYNOMIAL_PRIME2 evaluates the second derivative of the Legendre polynomial P(N,X). Computed N X P"(N,X) 0 -1.000000 0 1 -1.000000 0 2 -1.000000 3 3 -1.000000 -15 4 -1.000000 45 5 -1.000000 -105 0 -0.800000 0 1 -0.800000 0 2 -0.800000 3 3 -0.800000 -12 4 -0.800000 26.1 5 -0.800000 -38.64 0 -0.600000 0 1 -0.600000 0 2 -0.600000 3 3 -0.600000 -9 4 -0.600000 11.4 5 -0.600000 -2.52 0 -0.400000 0 1 -0.400000 0 2 -0.400000 3 3 -0.400000 -6 4 -0.400000 0.9 5 -0.400000 10.92 0 -0.200000 0 1 -0.200000 0 2 -0.200000 3 3 -0.200000 -3 4 -0.200000 -5.4 5 -0.200000 9.24 0 0.000000 0 1 0.000000 0 2 0.000000 3 3 0.000000 0 4 0.000000 -7.5 5 0.000000 -0 0 0.200000 0 1 0.200000 0 2 0.200000 3 3 0.200000 3 4 0.200000 -5.4 5 0.200000 -9.24 0 0.400000 0 1 0.400000 0 2 0.400000 3 3 0.400000 6 4 0.400000 0.9 5 0.400000 -10.92 0 0.600000 0 1 0.600000 0 2 0.600000 3 3 0.600000 9 4 0.600000 11.4 5 0.600000 2.52 0 0.800000 0 1 0.800000 0 2 0.800000 3 3 0.800000 12 4 0.800000 26.1 5 0.800000 38.64 0 1.000000 0 1 1.000000 0 2 1.000000 3 3 1.000000 15 4 1.000000 45 5 1.000000 105 P_POLYNOMIAL_VALUE_TEST: P_POLYNOMIAL_VALUE evaluates the Legendre polynomial P(n,x). Tabulated Computed N X P(N,X) P(N,X) Error 0 0.250000 1 1 0 1 0.250000 0.25 0.25 0 2 0.250000 -0.40625 -0.40625 0 3 0.250000 -0.335938 -0.335938 0 4 0.250000 0.157715 0.157715 0 5 0.250000 0.339722 0.339722 0 6 0.250000 0.0242767 0.0242767 0 7 0.250000 -0.279919 -0.279919 0 8 0.250000 -0.152454 -0.152454 -2.77556e-17 9 0.250000 0.176824 0.176824 0 10 0.250000 0.2212 0.2212 2.77556e-17 3 0.000000 0 -0 0 3 0.100000 -0.1475 -0.1475 0 3 0.200000 -0.28 -0.28 0 3 0.300000 -0.3825 -0.3825 0 3 0.400000 -0.44 -0.44 -5.55112e-17 3 0.500000 -0.4375 -0.4375 0 3 0.600000 -0.36 -0.36 5.55112e-17 3 0.700000 -0.1925 -0.1925 1.11022e-16 3 0.800000 0.08 0.08 -2.22045e-16 3 0.900000 0.4725 0.4725 -1.11022e-16 3 1.000000 1 1 0 p_polynomial_zeros_test: p_polynomial_zeros() computes the zeros of P(n,x) Check by calling p_polynomial_value() there. P(1,x) zeros from p_polynomial_zeros() 1: 0 P(1,x) zeros from MATLAB roots() 1: 0 Evaluate P(1,z) 1: 0 P(2,x) zeros from p_polynomial_zeros() 1: -0.57735 2: 0.57735 P(2,x) zeros from MATLAB roots() 1: -0.57735 2: 0.57735 Evaluate P(2,z) 1: -2.77556e-16 2: -2.77556e-16 P(3,x) zeros from p_polynomial_zeros() 1: -0.774597 2: 1.99493e-17 3: 0.774597 P(3,x) zeros from MATLAB roots() 1: -0.774597 2: 0 3: 0.774597 Evaluate P(3,z) 1: 2.22045e-16 2: -2.9924e-17 3: -6.66134e-16 P(4,x) zeros from p_polynomial_zeros() 1: -0.861136 2: -0.339981 3: 0.339981 4: 0.861136 P(4,x) zeros from MATLAB roots() 1: -0.861136 2: -0.339981 3: 0.339981 4: 0.861136 Evaluate P(4,z) 1: 5.55112e-16 2: 5.55112e-17 3: 5.55112e-17 4: -1.66533e-16 P(5,x) zeros from p_polynomial_zeros() 1: -0.90618 2: -0.538469 3: -1.08185e-16 4: 0.538469 5: 0.90618 P(5,x) zeros from MATLAB roots() 1: -0.90618 2: -0.538469 3: 0 4: 0.538469 5: 0.90618 Evaluate P(5,z) 1: -9.76996e-16 2: -3.10862e-16 3: -2.02848e-16 4: -4.44089e-17 5: -1.06581e-15 P_POWER_PRODUCT_TEST: P_POWER_PRODUCT computes a power product table for P(n,x): Tij = integral ( -1 <= x <= +1 ) x^e P(i,x) P(j,x) dx Maximum degree P = 5 Exponent of X, E = 0 Power product table: Col: 1 2 3 4 5 Row 1 : 2 3.05311e-16 9.71445e-16 1.38778e-16 5.68989e-16 2 : 3.05311e-16 0.666667 1.66533e-16 7.21645e-16 2.35922e-16 3 : 9.71445e-16 1.66533e-16 0.4 2.35922e-16 3.60822e-16 4 : 1.38778e-16 7.49401e-16 2.22045e-16 0.285714 2.77556e-17 5 : 5.68989e-16 2.35922e-16 3.747e-16 1.38778e-17 0.222222 6 : 3.19189e-16 2.01228e-16 0 2.67147e-16 4.33681e-17 Col: 6 Row 1 : 3.19189e-16 2 : 1.80411e-16 3 : 3.46945e-18 4 : 2.60209e-16 5 : 5.0307e-17 6 : 0.181818 P_POWER_PRODUCT_TEST: P_POWER_PRODUCT computes a power product table for P(n,x): Tij = integral ( -1 <= x <= +1 ) x^e P(i,x) P(j,x) dx Maximum degree P = 5 Exponent of X, E = 1 Power product table: Col: 1 2 3 4 5 Row 1 : 9.15934e-16 0.666667 2.08167e-16 -3.60822e-16 -3.46945e-16 2 : 0.666667 4.30211e-16 0.266667 -1.38778e-16 -3.747e-16 3 : 2.08167e-16 0.266667 1.38778e-17 0.171429 -2.77556e-16 4 :-3.60822e-16 -1.38778e-16 0.171429 -1.66533e-16 0.126984 5 :-3.46945e-16 -3.747e-16 -2.63678e-16 0.126984 -1.38778e-17 6 :-3.95517e-16 -4.23273e-16 -3.26128e-16 -9.71445e-17 0.10101 Col: 6 Row 1 :-3.95517e-16 2 : -4.3715e-16 3 :-3.26128e-16 4 :-1.04083e-16 5 : 0.10101 6 : 2.77556e-17 P_QUADRATURE_RULE_TEST: P_QUADRATURE_RULE computes the quadrature rule associated with P(n,x) X W 1: -0.90618 0.236927 2: -0.538469 0.478629 3: -1.08185e-16 0.568889 4: 0.538469 0.478629 5: 0.90618 0.236927 Use the quadrature rule to estimate: Q = Integral ( -1 <= X < +1 ) X^E dx E Q_Estimate Q_Exact 0 2 2 1 0 0 2 0.666667 0.666667 3 -1.11022e-16 0 4 0.4 0.4 5 -2.22045e-16 0 6 0.285714 0.285714 7 -2.498e-16 0 8 0.222222 0.222222 9 -2.498e-16 0 PM_POLYNOMIAL_VALUE_TEST: PM_POLYNOMIAL_VALUE evaluates the Legendre polynomial Pm(n,m,x). Tabulated Computed N M X Pm(N,M,X) Pm(N,M,X) Error 1 0 0.000000 0 0 0 2 0 0.000000 -0.5 -0.5 0 3 0 0.000000 0 -0 0 4 0 0.000000 0.375 0.375 0 5 0 0.000000 0 0 0 1 1 0.500000 -0.866025 -0.866025 0 2 1 0.500000 -1.29904 -1.29904 0 3 1 0.500000 -0.32476 -0.32476 0 4 1 0.500000 1.35316 1.35316 -4.44089e-16 3 0 0.200000 -0.28 -0.28 0 3 1 0.200000 1.17576 1.17576 -4.44089e-16 3 2 0.200000 2.88 2.88 0 3 3 0.200000 -14.1091 -14.1091 -7.10543e-15 4 2 0.250000 -3.95508 -3.95508 4.44089e-16 5 2 0.250000 -9.99756 -9.99756 1.77636e-15 6 3 0.250000 82.6531 82.6531 -1.42109e-14 7 3 0.250000 20.2444 20.2444 -1.06581e-14 8 4 0.250000 -423.8 -423.8 -5.68434e-14 9 4 0.250000 1638.32 1638.32 0 10 5 0.250000 -20256.9 -20256.9 3.63798e-12 PMN_POLYNOMIAL_VALUE_TEST: PMN_POLYNOMIAL_VALUE evaluates the Legendre polynomial Pmn(n,m,x). Tabulated Computed N M X Pmn(N,M,X) Pmn(N,M,X) Error 0 0 0.5 0.707107 0.707107 -1.11022e-16 1 0 0.5 0.612372 0.612372 0 1 1 0.5 -0.75 -0.75 -1.11022e-16 2 0 0.5 -0.197642 -0.197642 2.77556e-17 2 1 0.5 -0.838525 -0.838525 1.11022e-16 2 2 0.5 0.726184 0.726184 1.11022e-16 3 0 0.5 -0.818488 -0.818488 0 3 1 0.5 -0.17539 -0.17539 2.77556e-17 3 2 0.5 0.960652 0.960652 0 3 3 0.5 -0.679283 -0.679283 1.11022e-16 4 0 0.5 -0.613194 -0.613194 -1.11022e-16 4 1 0.5 0.641862 0.641862 0 4 2 0.5 0.471671 0.471671 0 4 3 0.5 -1.01892 -1.01892 0 4 4 0.5 0.623962 0.623962 1.11022e-16 5 0 0.5 0.210702 0.210702 -2.77556e-17 5 1 0.5 0.825631 0.825631 1.11022e-16 5 2 0.5 -0.398265 -0.398265 -5.55112e-17 5 3 0.5 -0.70404 -0.70404 -1.11022e-16 5 4 0.5 1.03472 1.03472 4.44089e-16 5 5 0.5 -0.566741 -0.566741 0 PMNS_POLYNOMIAL_VALUE_TEST: PMNS_POLYNOMIAL_VALUE evaluates the Legendre polynomial Pmns(n,m,x). Tabulated Computed N M X Pmns(N,M,X) Pmns(N,M,X) Error 0 0 0.5 0.282095 0.282095 -5.55112e-17 1 0 0.5 0.244301 0.244301 2.77556e-17 1 1 0.5 -0.299207 -0.299207 0 2 0 0.5 -0.0788479 -0.0788479 1.38778e-17 2 1 0.5 -0.334523 -0.334523 -5.55112e-17 2 2 0.5 0.289706 0.289706 5.55112e-17 3 0 0.5 -0.326529 -0.326529 0 3 1 0.5 -0.0699706 -0.0699706 0 3 2 0.5 0.383245 0.383245 -5.55112e-17 3 3 0.5 -0.270995 -0.270995 5.55112e-17 4 0 0.5 -0.244629 -0.244629 -2.77556e-17 4 1 0.5 0.256066 0.256066 0 4 2 0.5 0.188169 0.188169 2.77556e-17 4 3 0.5 -0.406492 -0.406492 5.55112e-17 4 4 0.5 0.248925 0.248925 -5.55112e-17 5 0 0.5 0.084058 0.084058 -1.38778e-17 5 1 0.5 0.329379 0.329379 0 5 2 0.5 -0.158885 -0.158885 2.77556e-17 5 3 0.5 -0.280871 -0.280871 0 5 4 0.5 0.412795 0.412795 0 5 5 0.5 -0.226097 -0.226097 2.77556e-17 PN_PAIR_PRODUCT_TEST PN_PAIR_PRODUCT computes a pair product table for Pn(n,x): Tij = integral ( -1 <= x <= +1 ) Pn(i,x) Pn(j,x) dx The Pn(n,x) polynomials are orthonormal, so T should be the identity matrix. Maximum degree P = 5 Pair product table: Col: 1 2 3 4 5 Row 1 : 1 -8.39606e-16 -2.52576e-15 -6.245e-16 1.60982e-15 2 :-7.56339e-16 1 -1.249e-15 -8.46545e-16 -1.38778e-16 3 :-2.48412e-15 -1.27676e-15 1 -6.38378e-16 -1.52656e-15 4 : -6.245e-16 -8.04912e-16 -6.10623e-16 1 -1.19349e-15 5 : 1.59595e-15 -1.11022e-16 -1.63758e-15 -1.19349e-15 1 6 : 4.71845e-16 9.71445e-16 -8.04912e-16 -6.66134e-16 -1.33227e-15 Col: 6 Row 1 : 5.13478e-16 2 : 9.57567e-16 3 :-8.32667e-16 4 :-6.66134e-16 5 :-1.41553e-15 6 : 1 PN_POLYNOMIAL_COEFFICIENTS_TEST PN_POLYNOMIAL_COEFFICIENTS: polynomial coefficients of Pn(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 pn_polynomial_plot_test: pn_polynomial_plot() creates a plot of one or more normalized Legendre functions. Graphics saved as "pn_polynomial_plot.png". PN_POLYNOMIAL_VALUE_TEST: PN_POLYNOMIAL_VALUE evaluates the normalized Legendre polynomial Pn(n,x). Tabulated Computed N X Pn(N,X) Pn(N,X) Error 0 0.250000 0.7071067811865475 0.7071067811865475 0 1 0.250000 0.3061862178478972 0.3061862178478972 -5.55112e-17 2 0.250000 -0.642337649721702 -0.642337649721702 0 3 0.250000 -0.6284815141846855 -0.6284815141846855 0 4 0.250000 0.3345637065282053 0.3345637065282053 -5.55112e-17 5 0.250000 0.7967179601799685 0.7967179601799685 0 6 0.250000 0.06189376866246124 0.06189376866246124 0 7 0.250000 -0.766588850921089 -0.766588850921089 0 8 0.250000 -0.4444760242953344 -0.4444760242953344 0 9 0.250000 0.5450094674858101 0.5450094674858101 0 10 0.250000 0.7167706229835538 0.7167706229835538 0 3 0.000000 0 -0 0 3 0.100000 -0.2759472322745781 -0.2759472322745781 0 3 0.200000 -0.5238320341483518 -0.5238320341483518 0 3 0.300000 -0.7155919752205163 -0.7155919752205163 0 3 0.400000 -0.823164625090267 -0.823164625090267 0 3 0.500000 -0.8184875533567997 -0.8184875533567997 0 3 0.600000 -0.6734983296193094 -0.6734983296193094 0 3 0.700000 -0.360134523476992 -0.360134523476992 5.55112e-17 3 0.800000 0.1496662954709581 0.1496662954709581 5.55112e-17 3 0.900000 0.8839665576253438 0.8839665576253438 0 3 1.000000 1.870828693386971 1.870828693386971 4.44089e-16 legendre_polynomial_test(): Normal end of execution. 07-Jan-2022 22:47:09