private static void test05() //****************************************************************************80 // // Purpose: // // TEST05 tests P00_GAUSS_HERMITE against the polynomials. // // Licensing: // // This code is distributed under the GNU LGPL license. // // Modified: // // 26 May 2009 // // Author: // // John Burkardt // { int m; Problem00.p00Data data = new(); Console.WriteLine(""); Console.WriteLine("TEST05"); Console.WriteLine(" P00_GAUSS_HERMITE applies a Gauss-Hermite rule to"); Console.WriteLine(" estimate the integral x^m exp(-x*x) over (-oo,+oo)."); const int problem = 6; Console.WriteLine(""); Console.WriteLine(" M Order Estimate Exact Error"); for (m = 0; m <= 6; m++) { Problem06.p06_param(ref data.p6data, 'S', 'M', ref m); double exact = Problem00.p00_exact(ref data, problem); Console.WriteLine(""); int order; for (order = 1; order <= 3 + m / 2; order++) { double estimate = Problem00.p00_gauss_hermite(ref data, problem, order); double error = Math.Abs(exact - estimate); Console.WriteLine(" " + m.ToString(CultureInfo.InvariantCulture).PadLeft(8) + " " + order.ToString(CultureInfo.InvariantCulture).PadLeft(8) + " " + estimate.ToString(CultureInfo.InvariantCulture).PadLeft(14) + " " + exact.ToString(CultureInfo.InvariantCulture).PadLeft(14) + " " + error.ToString(CultureInfo.InvariantCulture).PadLeft(14) + ""); } } }
private static void test03() //****************************************************************************80 // // Purpose: // // TEST03 tests P00_GAUSS_HERMITE. // // Licensing: // // This code is distributed under the GNU LGPL license. // // Modified: // // 26 May 2009 // // Author: // // John Burkardt // { int problem; Problem00.p00Data data = new(); Console.WriteLine(""); Console.WriteLine("TEST03"); Console.WriteLine(" P00_GAUSS_HERMITE applies a Gauss-Hermite rule"); Console.WriteLine(" to estimate an integral on (-oo,+oo)."); int problem_num = Problem00.p00_problem_num(); int m = 4; Problem06.p06_param(ref data.p6data, 'S', 'M', ref m); Console.WriteLine(""); Console.WriteLine(" Problem Order Estimate Exact Error"); for (problem = 1; problem <= problem_num; problem++) { double exact = Problem00.p00_exact(ref data, problem); int order = 1; Console.WriteLine(""); int order_log; for (order_log = 0; order_log <= 6; order_log++) { double estimate = Problem00.p00_gauss_hermite(ref data, problem, order); double error = Math.Abs(exact - estimate); Console.WriteLine(" " + problem.ToString(CultureInfo.InvariantCulture).PadLeft(8) + " " + order.ToString(CultureInfo.InvariantCulture).PadLeft(8) + " " + estimate.ToString("0.######").PadLeft(14) + " " + exact.ToString("0.######").PadLeft(14) + " " + error.ToString("0.######").PadLeft(14) + ""); order *= 2; } } }