Ejemplo n.º 1
0
    private static void lobatto_polynomial_derivative_test()

    //****************************************************************************80
    //
    //  Purpose:
    //
    //    LOBATTO_POLYNOMIAL_DERIVATIVE_TEST tests LOBATTO_POLYNOMIAL_DERIVATIVE.
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    20 November 2014
    //
    //  Author:
    //
    //    John Burkardt
    //
    {
        double fx1 = 0;
        int    n   = 0;
        double x   = 0;

        double[] xvec = new double[1];

        const int m = 1;

        Console.WriteLine("");
        Console.WriteLine("LOBATTO_POLYNOMIAL_DERIVATIVE_TEST:");
        Console.WriteLine("  LOBATTO_POLYNOMIAL_DERIVATIVES stores derivatives of");
        Console.WriteLine("  the completed Lobatto polynomial L(n,x).");
        Console.WriteLine("  LOBATTO_POLYNOMIAL_DERIVATIVE evaluates the completed Lobatto polynomial.");
        Console.WriteLine("");
        Console.WriteLine("                                       Tabulated                 Computed");
        Console.WriteLine("     N        X                        L''(N,X)                   L''(N,X)       Error");
        Console.WriteLine("");

        int n_data = 0;

        for (;;)
        {
            Lobatto.lobatto_polynomial_derivatives(ref n_data, ref n, ref x, ref fx1);

            if (n_data == 0)
            {
                break;
            }

            xvec[0] = x;
            double[] lp  = Lobatto.lobatto_polynomial_derivative(m, n, xvec);
            double   fx2 = lp[0 + (n - 1) * m];

            double e = fx1 - fx2;

            Console.WriteLine("  " + n.ToString(CultureInfo.InvariantCulture).PadLeft(4)
                              + "  " + x.ToString(CultureInfo.InvariantCulture).PadLeft(12)
                              + "  " + fx1.ToString(CultureInfo.InvariantCulture).PadLeft(12)
                              + "  " + fx2.ToString(CultureInfo.InvariantCulture).PadLeft(12)
                              + "  " + e.ToString(CultureInfo.InvariantCulture).PadLeft(8) + "");
        }
    }