Example #1
0
    private static void hermite_polynomial_test03()

    //****************************************************************************80
    //
    //  Purpose:
    //
    //    HERMITE_POLYNOMIAL_TEST03 tests HF_FUNCTION_VALUE.
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    26 February 2012
    //
    //  Author:
    //
    //    John Burkardt
    //
    {
        int    n_data;
        double e;
        double fx1 = 0;
        double fx2;

        double[] fx2_vec;
        int      n = 0;
        double   x = 0;

        double[] x_vec = new double[1];

        Console.WriteLine("");
        Console.WriteLine("HERMITE_POLYNOMIAL_TEST03:");
        Console.WriteLine("  HF_FUNCTION_VALUES stores values of");
        Console.WriteLine("  the Hermite function Hf(n,x).");
        Console.WriteLine("  HF_FUNCTION_VALUE evaluates the function.");
        Console.WriteLine("");
        Console.WriteLine("                        Tabulated                 Computed");
        Console.WriteLine("     N        X          Hf(N,X)                   Hf(N,X)                   Error");
        Console.WriteLine("");

        n_data = 0;

        for (;;)
        {
            Burkardt.Values.Hermite.hf_function_values(ref n_data, ref n, ref x, ref fx1);

            if (n_data == 0)
            {
                break;
            }

            x_vec[0] = x;
            fx2_vec  = Hermite.hf_function_value(1, n, x_vec);
            fx2      = fx2_vec[n];

            e = fx1 - fx2;

            Console.WriteLine("  " + n.ToString().PadLeft(4)
                              + "  " + x.ToString().PadLeft(12)
                              + "  " + fx1.ToString("0.################").PadLeft(24)
                              + "  " + fx2.ToString("0.################").PadLeft(24)
                              + "  " + e.ToString("0.######").PadLeft(14) + "");
        }
    }