public static void pn_polynomial_value_test() //****************************************************************************80 // // Purpose: // // PN_POLYNOMIAL_VALUE_TEST tests PN_POLYNOMIAL_VALUE. // // Licensing: // // This code is distributed under the GNU LGPL license. // // Modified: // // 18 March 2012 // // Author: // // John Burkardt // { double fx1 = 0; int n = 0; double x = 0; double[] x_vec = new double[1]; Console.WriteLine(""); Console.WriteLine("PN_POLYNOMIAL_VALUE_TEST:"); Console.WriteLine(" PN_POLYNOMIAL_VALUE evaluates the normalized Legendre polynomial Pn(n,x)."); Console.WriteLine(""); Console.WriteLine(" Tabulated Computed"); Console.WriteLine(" N X Pn(N,X) Pn(N,X) Error"); Console.WriteLine(""); int n_data = 0; for (;;) { Burkardt.Values.Legendre.pn_polynomial_values(ref n_data, ref n, ref x, ref fx1); if (n_data == 0) { break; } x_vec[0] = x; double[] fx2_vec = Legendre.pn_polynomial_value(1, n, x_vec); double fx2 = fx2_vec[n]; double e = fx1 - fx2; Console.WriteLine(" " + n.ToString(CultureInfo.InvariantCulture).PadLeft(4) + " " + x.ToString(CultureInfo.InvariantCulture).PadLeft(12) + " " + fx1.ToString("0.################").PadLeft(24) + " " + fx2.ToString("0.################").PadLeft(24) + " " + e.ToString(CultureInfo.InvariantCulture).PadLeft(8) + ""); } }
public void lpmvTest() { for (int i = 0; i <= 5; i++) { double a = Legendre.lpmv(5, i, Math.PI / 3); Console.WriteLine(a); } }
public static void lpp_to_polynomial_test() //****************************************************************************80 // // Purpose: // // LPP_TO_POLYNOMIAL_TEST tests LPP_TO_POLYNOMIAL. // // Licensing: // // This code is distributed under the GNU LGPL license. // // Modified: // // 11 September 2014 // // Author: // // John Burkardt // { const int m = 2; int o = 0; int rank; Console.WriteLine(""); Console.WriteLine("LPP_TO_POLYNOMIAL_TEST:"); Console.WriteLine(" LPP_TO_POLYNOMIAL is given a Legendre product polynomial"); Console.WriteLine(" and determines its polynomial representation."); Console.WriteLine(""); Console.WriteLine(" Using spatial dimension M = " + m + ""); for (rank = 1; rank <= 11; rank++) { int[] l = Comp.comp_unrank_grlex(m, rank); int o_max = 1; int i; for (i = 0; i < m; i++) { o_max = o_max * (l[i] + 2) / 2; } double[] c = new double[o_max]; int[] e = new int[o_max]; Legendre.lpp_to_polynomial(m, l, o_max, ref o, ref c, ref e); string label = " LPP #" + rank + " = L(" + l[0] + ",X)*L(" + l[1] + ",Y) = "; Console.WriteLine(""); Polynomial.polynomial_print(m, o, c, e, label); } }
public static void p_polynomial_prime2_test() //****************************************************************************80 // // Purpose: // // P_POLYNOMIAL_PRIME2_TEST tests P_POLYNOMIAL_PRIME2. // // Licensing: // // This code is distributed under the GNU LGPL license. // // Modified: // // 04 May 2013 // // Author: // // John Burkardt // { int i; Console.WriteLine(""); Console.WriteLine("P_POLYNOMIAL_PRIME2_TEST:"); Console.WriteLine(" P_POLYNOMIAL_PRIME2 evaluates the second derivative of the"); Console.WriteLine(" Legendre polynomial P(n,x)."); Console.WriteLine(""); Console.WriteLine(" Computed"); Console.WriteLine(" N X P\"(N,X)"); Console.WriteLine(""); const int m = 11; const double a = -1.0; const double b = +1.0; double[] x = typeMethods.r8vec_linspace_new(m, a, b); const int n = 5; double[] vpp = Legendre.p_polynomial_prime2(m, n, x); for (i = 0; i < m; i++) { Console.WriteLine(""); int j; for (j = 0; j <= n; j++) { Console.WriteLine(" " + j.ToString(CultureInfo.InvariantCulture).PadLeft(4) + " " + x[i].ToString(CultureInfo.InvariantCulture).PadLeft(12) + " " + vpp[i + j * m].ToString("0.################").PadLeft(24) + ""); } } }
public static void legendre_associated_values_test() //****************************************************************************80 // // Purpose: // // LEGENDRE_ASSOCIATED_VALUES_TEST tests LEGENDRE_ASSOCIATED_VALUES. // // Licensing: // // This code is distributed under the GNU LGPL license. // // Modified: // // 12 June 2007 // // Author: // // John Burkardt // { double fx = 0; int m = 0; int n = 0; double x = 0; Console.WriteLine(""); Console.WriteLine("LEGENDRE_ASSOCIATED_VALUES_TEST:"); Console.WriteLine(" LEGENDRE_ASSOCIATED_VALUES stores values of"); Console.WriteLine(" the associated Legendre polynomials."); Console.WriteLine(""); Console.WriteLine(" N M X P(N,M)(X)"); Console.WriteLine(""); int n_data = 0; for (;;) { Legendre.legendre_associated_values(ref n_data, ref n, ref m, ref x, ref fx); if (n_data == 0) { break; } Console.WriteLine(" " + n.ToString(CultureInfo.InvariantCulture).PadLeft(6) + " " + m.ToString(CultureInfo.InvariantCulture).PadLeft(6) + " " + x.ToString(CultureInfo.InvariantCulture).PadLeft(12) + " " + fx.ToString("0.################").PadLeft(24) + ""); } }
public static void lp_coefficients_test() //****************************************************************************80 // // Purpose: // // LP_COEFFICIENTS_TEST tests LP_COEFFICIENTS. // // Licensing: // // This code is distributed under the GNU LGPL license. // // Modified: // // 30 October 2014 // // Author: // // John Burkardt // { const int m = 1; int n; const int N_MAX = 10; int o = 0; Console.WriteLine(""); Console.WriteLine("LP_COEFFICIENTS_TEST"); Console.WriteLine(" LP_COEFFICIENTS: coefficients of Legendre polynomial P(n,x)."); Console.WriteLine(""); for (n = 0; n <= N_MAX; n++) { double[] c = new double[n + 1]; int[] f = new int[n + 1]; Legendre.lp_coefficients(n, ref o, ref c, ref f); int[] e = new int[o]; int i; for (i = 0; i < o; i++) { e[i] = f[i] + 1; } string label = " P(" + n + ",x) = "; Polynomial.polynomial_print(m, o, c, e, label); } }
public void Symbol_BigValue_Test() { // secp256k1 prime BigInteger prime = BigInteger.Parse("115792089237316195423570985008687907853269984665640564039457584007908834671663"); Random rnd = new Random(); byte[] ba = new byte[32]; rnd.NextBytes(ba); BigInteger n = ba.ToBigInt(true, true); BigInteger ls = BigInteger.ModPow(n, (prime - 1) / 2, prime); int expected = (ls == prime - 1) ? -1 : (int)ls; int actual = Legendre.Symbol(n, prime); Assert.Equal(expected, actual); }
public static void legendre_function_q_values_test() //****************************************************************************80 // // Purpose: // // LEGENDRE_FUNCTION_Q_VALUES_TEST tests LEGENDRE_FUNCTION_Q_VALUES. // // Licensing: // // This code is distributed under the GNU LGPL license. // // Modified: // // 13 June 2007 // // Author: // // John Burkardt // { double fx = 0; int n = 0; double x = 0; Console.WriteLine(""); Console.WriteLine("LEGENDRE_FUNCTION_Q_VALUES_TEST:"); Console.WriteLine(" LEGENDRE_FUNCTION_Q_VALUES stores values of"); Console.WriteLine(" the Legendre Q function."); Console.WriteLine(""); Console.WriteLine(" N X Q(N)(X)"); Console.WriteLine(""); int n_data = 0; for (;;) { Legendre.legendre_function_q_values(ref n_data, ref n, ref x, ref fx); if (n_data == 0) { break; } Console.WriteLine(" " + n.ToString(CultureInfo.InvariantCulture).PadLeft(6) + " " + x.ToString(CultureInfo.InvariantCulture).PadLeft(12) + " " + fx.ToString("0.################").PadLeft(24) + ""); } }
public static void legendre_normalized_polynomial_values_test() //****************************************************************************80 // // Purpose: // // LEGENDRE_NORMALIZED_POLYNOMIAL_VALUES_TEST tests LEGENDRE_NORMALIZED_POLYNOMIAL_VALUES. // // Licensing: // // This code is distributed under the GNU LGPL license. // // Modified: // // 18 March 2016 // // Author: // // John Burkardt // { double fx = 0; int n = 0; double x = 0; Console.WriteLine(""); Console.WriteLine("LEGENDRE_NORMALIZED_POLYNOMIAL_VALUES_TEST:"); Console.WriteLine(" LEGENDRE_NORMALIZED_POLYNOMIAL_VALUES stores values of "); Console.WriteLine(" the normalized Legendre polynomials."); Console.WriteLine(""); Console.WriteLine(" N X Pn(N)(X)"); Console.WriteLine(""); int n_data = 0; for (;;) { Legendre.legendre_normalized_polynomial_values(ref n_data, ref n, ref x, ref fx); if (n_data == 0) { break; } Console.WriteLine(" " + n.ToString(CultureInfo.InvariantCulture).PadLeft(6) + " " + x.ToString(CultureInfo.InvariantCulture).PadLeft(12) + " " + fx.ToString("0.################").PadLeft(24) + ""); } }
public static IPolynomial SquareRoot(IPolynomial startPolynomial, IPolynomial f, BigInteger p, int degree, BigInteger m) { BigInteger q = BigInteger.Pow(p, degree); BigInteger s = q - 1; int r = 0; while (s.Mod(2) == 0) { s /= 2; r++; } BigInteger halfS = ((s + 1) / 2); if (r == 1 && q.Mod(4) == 3) { halfS = ((q + 1) / 4); } BigInteger quadraticNonResidue = Legendre.SymbolSearch(m + 1, q, -1); BigInteger theta = quadraticNonResidue; BigInteger minusOne = BigInteger.ModPow(theta, ((q - 1) / 2), p); IPolynomial omegaPoly = Polynomial.Field.ExponentiateMod(startPolynomial, halfS, f, p); BigInteger lambda = minusOne; BigInteger zeta = 0; int i = 0; do { i++; zeta = BigInteger.ModPow(theta, (i * s), p); lambda = (lambda * BigInteger.Pow(zeta, (int)Math.Pow(2, (r - i)))).Mod(p); omegaPoly = Polynomial.Field.Multiply(omegaPoly, BigInteger.Pow(zeta, (int)Math.Pow(2, ((r - i) - 1))), p); }while (!((lambda == 1) || (i > (r)))); return(omegaPoly); }
public static void p_exponential_product_test(int p, double b) //****************************************************************************80 // // Purpose: // // P_EXPONENTIAL_PRODUCT_TEST tests P_EXPONENTIAL_PRODUCT. // // Licensing: // // This code is distributed under the GNU LGPL license. // // Modified: // // 14 March 2012 // // Author: // // John Burkardt // // Parameters: // // Input, int P, the maximum degree of the polynomial // factors. // // Input, double B, the coefficient of X in the exponential factor. // { Console.WriteLine(""); Console.WriteLine("P_EXPONENTIAL_PRODUCT_TEST"); Console.WriteLine(" P_EXPONENTIAL_PRODUCT_TEST computes a Legendre exponential product table."); Console.WriteLine(""); Console.WriteLine(" Tij = integral ( -1.0 <= X <= +1.0 ) exp(B*X) P(I,X) P(J,X) dx"); Console.WriteLine(""); Console.WriteLine(" where P(I,X) = Legendre polynomial of degree I."); Console.WriteLine(""); Console.WriteLine(" Maximum degree P = " + p + ""); Console.WriteLine(" Exponential argument coefficient B = " + b + ""); double[] table = Legendre.p_exponential_product(p, b); typeMethods.r8mat_print(p + 1, p + 1, table, " Exponential product table:"); }
public static void p_power_product_test(int p, int e) //****************************************************************************80 // // Purpose: // // P_POWER_PRODUCT_TEST tests P_POWER_PRODUCT. // // Licensing: // // This code is distributed under the GNU LGPL license. // // Modified: // // 14 March 2012 // // Author: // // John Burkardt // // Parameters: // // Input, int P, the maximum degree of the polynomial // factors. // // Input, int E, the exponent of X. // { Console.WriteLine(""); Console.WriteLine("P_POWER_PRODUCT_TEST"); Console.WriteLine(" P_POWER_PRODUCT_TEST computes a Legendre power product table."); Console.WriteLine(""); Console.WriteLine(" Tij = integral ( -1.0 <= X <= +1.0 ) X^E P(I,X) P(J,X) dx"); Console.WriteLine(""); Console.WriteLine(" where P(I,X) = Legendre polynomial of degree I."); Console.WriteLine(""); Console.WriteLine(" Maximum degree P = " + p + ""); Console.WriteLine(" Exponent of X, E = " + e + ""); double[] table = Legendre.p_power_product(p, e); typeMethods.r8mat_print(p + 1, p + 1, table, " Power product table:"); }
public static void pn_pair_product_test(int p) //****************************************************************************80 // // Purpose: // // PN_PAIR_PRODUCT_TEST tests PN_PAIR_PRODUCT. // // Licensing: // // This code is distributed under the GNU LGPL license. // // Modified: // // 14 March 2012 // // Author: // // John Burkardt // // Parameters: // // Input, int P, the maximum degree of the polynomial // factors. // { Console.WriteLine(""); Console.WriteLine("PN_PAIR_PRODUCT_TEST:"); Console.WriteLine(" PN_PAIR_PRODUCT_TEST computes a pair product table for Pn(n,x)."); Console.WriteLine(""); Console.WriteLine(" Tij = integral ( -1.0 <= X <= +1.0 ) Pn(I,X) Pn(J,X) dx"); Console.WriteLine(""); Console.WriteLine(" where Pn(I,X) = normalized Legendre polynomial of degree I."); Console.WriteLine(""); Console.WriteLine(" Maximum degree P = " + p + ""); double[] table = Legendre.pn_pair_product(p); typeMethods.r8mat_print(p + 1, p + 1, table, " Pair product table:"); }
public static void p_polynomial_zeros_test() //****************************************************************************80 // // Purpose: // // P_POLYNOMIAL_ZEROS_TEST tests P_POLYNOMIAL_ZEROS. // // Licensing: // // This code is distributed under the GNU LGPL license. // // Modified: // // 14 March 2012 // // Author: // // John Burkardt // { int degree; Console.WriteLine(""); Console.WriteLine("P_POLYNOMIAL_ZEROS_TEST:"); Console.WriteLine(" P_POLYNOMIAL_ZEROS computes the zeros of P(n,x)"); Console.WriteLine(" Check by calling P_POLYNOMIAL_VALUE there."); for (degree = 1; degree <= 5; degree++) { double[] z = Legendre.p_polynomial_zeros(degree); string title = " Computed zeros for P(" + degree + ",z):"; typeMethods.r8vec_print(degree, z, title); double[] hz = Legendre.p_polynomial_value(degree, degree, z); title = " Evaluate P(" + degree + ",z):"; typeMethods.r8vec_print(degree, hz, title, +degree * degree); } }
public static void p_integral_test() //****************************************************************************80 // // Purpose: // // P_INTEGRAL_TEST tests P_INTEGRAL. // // Licensing: // // This code is distributed under the GNU LGPL license. // // Modified: // // 15 March 2016 // // Author: // // John Burkardt // { int n; Console.WriteLine(""); Console.WriteLine("P_INTEGRAL_TEST:"); Console.WriteLine(" P_INTEGRAL returns the integral of P(n,x) over [-1,+1]."); Console.WriteLine(""); Console.WriteLine(" N Integral"); Console.WriteLine(""); for (n = 0; n <= 10; n++) { double value = Legendre.p_integral(n); Console.WriteLine(" " + n.ToString(CultureInfo.InvariantCulture).PadLeft(4) + " " + value.ToString(CultureInfo.InvariantCulture).PadLeft(14) + ""); } }
public static int jacobi_symbol(int q, int p) //****************************************************************************80 // // Purpose: // // JACOBI_SYMBOL evaluates the Jacobi symbol (Q/P). // // Discussion: // // If P is prime, then // // Jacobi Symbol (Q/P) = Legendre Symbol (Q/P) // // Else // // let P have the prime factorization // // P = Product ( 1 <= I <= N ) P(I)^E(I) // // Jacobi Symbol (Q/P) = // // Product ( 1 <= I <= N ) Legendre Symbol (Q/P(I))^E(I) // // Licensing: // // This code is distributed under the GNU LGPL license. // // Modified: // // 30 June 2000 // // Author: // // John Burkardt // // Reference: // // Daniel Zwillinger, // CRC Standard Mathematical Tables and Formulae, // 30th Edition, // CRC Press, 1996, pages 86-87. // // Parameters: // // Input, int Q, an integer whose Jacobi symbol with // respect to P is desired. // // Input, int P, the number with respect to which the Jacobi // symbol of Q is desired. P should be 2 or greater. // // Output, int JACOBI_SYMBOL, the Jacobi symbol (Q/P). // Ordinarily, L will be -1, 0 or 1. // If JACOBI_SYMBOL is -10, an error occurred. // { const int FACTOR_MAX = 20; int[] factor = new int[FACTOR_MAX]; int i; int nfactor = 0; int nleft = 0; int[] power = new int[FACTOR_MAX]; switch (p) { // // P must be greater than 1. // case <= 1: Console.WriteLine(""); Console.WriteLine("JACOBI_SYMBOL - Fatal error!"); Console.WriteLine(" P must be greater than 1."); return(1); } // // Decompose P into factors of prime powers. // typeMethods.i4_factor(p, FACTOR_MAX, ref nfactor, ref factor, ref power, ref nleft); if (nleft != 1) { Console.WriteLine(""); Console.WriteLine("JACOBI_SYMBOL - Fatal error!"); Console.WriteLine(" Not enough factorization space."); return(1); } // // Force Q to be nonnegative. // while (q < 0) { q += p; } // // For each prime factor, compute the Legendre symbol, and // multiply the Jacobi symbol by the appropriate factor. // int value = 1; for (i = 0; i < nfactor; i++) { int l = Legendre.legendre_symbol(q, factor[i]); switch (l) { case < -1: Console.WriteLine(""); Console.WriteLine("JACOBI_SYMBOL - Fatal error!"); Console.WriteLine(" Error during Legendre symbol calculation."); return(1); default: value *= (int)Math.Pow(l, power[i]); break; } } return(value); }
public void Symbol_ExceptionTest() { Assert.Throws <ArithmeticException>(() => Legendre.Symbol(2, 1)); }
public void SymbolTest(BigInteger n, BigInteger p, int expected) { int actual = Legendre.Symbol(n, p); Assert.Equal(expected, actual); }
public static void p_quadrature_rule_test() //****************************************************************************80 // // Purpose: // // P_QUADRATURE_RULE_TEST tests P_QUADRATURE_RULE. // // Licensing: // // This code is distributed under the GNU LGPL license. // // Modified: // // 14 March 2012 // // Author: // // John Burkardt // { int e; Console.WriteLine(""); Console.WriteLine("P_QUADRATURE_RULE_TEST:"); Console.WriteLine(" P_QUADRATURE_RULE computes the quadrature rule"); Console.WriteLine(" associated with P(n,x)"); const int n = 7; double[] x = new double[n]; double[] w = new double[n]; LegendreQuadrature.p_quadrature_rule(n, ref x, ref w); typeMethods.r8vec2_print(n, x, w, " X W"); Console.WriteLine(""); Console.WriteLine(" Use the quadrature rule to estimate:"); Console.WriteLine(""); Console.WriteLine(" Q = Integral ( -1 <= X <= +1.0 ) X^E dx"); Console.WriteLine(""); Console.WriteLine(" E Q_Estimate Q_Exact"); Console.WriteLine(""); double[] f = new double[n]; for (e = 0; e <= 2 * n - 1; e++) { int i; switch (e) { case 0: { for (i = 0; i < n; i++) { f[i] = 1.0; } break; } default: { for (i = 0; i < n; i++) { f[i] = Math.Pow(x[i], e); } break; } } double q = typeMethods.r8vec_dot_product(n, w, f); double q_exact = Legendre.p_integral(e); Console.WriteLine(" " + e.ToString(CultureInfo.InvariantCulture).PadLeft(2) + " " + q.ToString(CultureInfo.InvariantCulture).PadLeft(14) + " " + q_exact.ToString(CultureInfo.InvariantCulture).PadLeft(14) + ""); } }
public static void pn_polynomial_coefficients_test() //****************************************************************************80 // // Purpose: // // PN_POLYNOMIAL_COEFFICIENTS_TEST tests PN_POLYNOMIAL_COEFFICIENTS. // // Licensing: // // This code is distributed under the GNU LGPL license. // // Modified: // // 18 October 2014 // // Author: // // John Burkardt // { int i; const int n = 10; Console.WriteLine(""); Console.WriteLine("PN_POLYNOMIAL_COEFFICIENTS_TEST"); Console.WriteLine(" PN_POLYNOMIAL_COEFFICIENTS: coefficients of normalized Legendre polynomial P(n,x)."); double[] c = Legendre.pn_polynomial_coefficients(n); for (i = 0; i <= n; i++) { Console.WriteLine(""); Console.WriteLine(" P(" + i + ",x) ="); Console.WriteLine(""); int j; for (j = i; 0 <= j; j--) { switch (c[i + j * (n + 1)]) { case 0.0: break; default: switch (j) { case 0: Console.WriteLine(c[i + j * (n + 1)].ToString(CultureInfo.InvariantCulture).PadLeft(14) + ""); break; case 1: Console.WriteLine(c[i + j * (n + 1)].ToString(CultureInfo.InvariantCulture).PadLeft(14) + " * x"); break; default: Console.WriteLine(c[i + j * (n + 1)].ToString(CultureInfo.InvariantCulture).PadLeft(14) + " * x^" + j + ""); break; } break; } } } }
public static void lpp_value_test() //****************************************************************************80 // // Purpose: // // LPP_VALUE_TEST tests LPP_VALUE. // // Licensing: // // This code is distributed under the GNU LGPL license. // // Modified: // // 31 October 2014 // // Author: // // John Burkardt // { int i; const int m = 3; const int n = 1; int o = 0; int rank; Console.WriteLine(""); Console.WriteLine("LPP_VALUE_TEST:"); Console.WriteLine(" LPP_VALUE evaluates a Legendre product polynomial."); const double xlo = -1.0; const double xhi = +1.0; int seed = 123456789; double[] x = UniformRNG.r8vec_uniform_ab_new(m, xlo, xhi, ref seed); Console.WriteLine(""); string cout = " Evaluate at X = "; for (i = 0; i < m; i++) { cout += " " + x[i + 0 * m]; } Console.WriteLine(cout); Console.WriteLine(""); Console.WriteLine(" Rank I1 I2 I3: L(I1,X1)*L(I2,X2)*L(I3,X3) P(X1,X2,X3)"); Console.WriteLine(""); for (rank = 1; rank <= 20; rank++) { int[] l = Comp.comp_unrank_grlex(m, rank); // // Evaluate the LPP directly. // double[] v1 = Legendre.lpp_value(m, n, l, x); // // Convert the LPP to a polynomial. // int o_max = 1; for (i = 0; i < m; i++) { o_max = o_max * (l[i] + 2) / 2; } double[] c = new double[o_max]; int[] e = new int[o_max]; Legendre.lpp_to_polynomial(m, l, o_max, ref o, ref c, ref e); // // Evaluate the polynomial. // double[] v2 = Polynomial.polynomial_value(m, o, c, e, n, x); // // Compare results. // Console.WriteLine(rank.ToString().PadLeft(6) + " " + l[0].ToString().PadLeft(2) + " " + l[1].ToString().PadLeft(2) + " " + l[2].ToString().PadLeft(2) + " " + v1[0].ToString(CultureInfo.InvariantCulture).PadLeft(14) + " " + v2[0].ToString(CultureInfo.InvariantCulture).PadLeft(14) + ""); } }
public static void lp_value_test() //****************************************************************************80 // // Purpose: // // LP_VALUE_TEST tests LP_VALUE. // // Licensing: // // This code is distributed under the GNU LGPL license. // // Modified: // // 11 September 2014 // // Author: // // John Burkardt // { int o = 0; double x = 0; double[] xvec = new double[1]; double fx1 = 0; const int n = 1; Console.WriteLine(""); Console.WriteLine("LP_VALUE_TEST:"); Console.WriteLine(" LP_VALUE evaluates a Legendre polynomial."); Console.WriteLine(""); Console.WriteLine(" Tabulated Computed"); Console.WriteLine(" O X L(O,X) L(O,X)" + " Error"); Console.WriteLine(""); int n_data = 0; for (;;) { Burkardt.Values.Legendre.lp_values(ref n_data, ref o, ref x, ref fx1); if (n_data == 0) { break; } xvec[0] = x; double[] fx2 = Legendre.lp_value(n, o, xvec); double e = fx1 - fx2[0]; Console.WriteLine(o.ToString(CultureInfo.InvariantCulture).PadLeft(6) + " " + x.ToString(CultureInfo.InvariantCulture).PadLeft(12) + " " + fx1.ToString(CultureInfo.InvariantCulture).PadLeft(24) + " " + fx2[0].ToString(CultureInfo.InvariantCulture).PadLeft(24) + " " + e.ToString(CultureInfo.InvariantCulture).PadLeft(8) + ""); } }