Exemple #1
0
        public virtual double HCoeffs(int s)
        {
            // TODO: use Gauss quadrature formula
            var coeffSym = mathlib.ScalarMul.LebesgueLaguerre(_right, Laguerre.Get(s));

            return(Integrals.RectangularInfinite(coeffSym, 100000, 10));
        }
Exemple #2
0
    public static void gen_laguerre_poly_test()

    //****************************************************************************80
    //
    //  Purpose:
    //
    //    GEN_LAGUERRE_POLY_TEST tests GEN_LAGUERRE_POLY.
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    23 May 2007
    //
    //  Author:
    //
    //    John Burkardt
    //
    {
        const int N      = 10;
        const int N_TEST = 6;

        double[] alpha_test = { 0.0, 0.0, 0.1, 0.1, 0.5, 1.0 };
        double[] c          = new double [N + 1];
        int      i;

        double[] x_test = { 0.0, 1.0, 0.0, 0.5, 0.5, 0.5 };

        Console.WriteLine("");
        Console.WriteLine("GEN_LAGUERRE_POLY_TEST");
        Console.WriteLine("  GEN_LAGUERRE_POLY evaluates the generalized Laguerre");
        Console.WriteLine("  functions.");

        for (i = 0; i < N_TEST; i++)
        {
            double x     = x_test[i];
            double alpha = alpha_test[i];

            Console.WriteLine("");
            Console.WriteLine("  Table of L(N,ALPHA)(X) for");
            Console.WriteLine("");
            Console.WriteLine("    N(max) = " + N + "");
            Console.WriteLine("    ALPHA =  " + alpha + "");
            Console.WriteLine("    X =      " + x + "");
            Console.WriteLine("");

            Laguerre.gen_laguerre_poly(N, alpha, x, ref c);

            int j;
            for (j = 0; j <= N; j++)
            {
                Console.WriteLine("  "
                                  + j.ToString(CultureInfo.InvariantCulture).PadLeft(6) + "  "
                                  + c[j].ToString(CultureInfo.InvariantCulture).PadLeft(14) + "");
            }
        }
    }
Exemple #3
0
    public static void laguerre_poly_test()

    //****************************************************************************80
    //
    //  Purpose:
    //
    //    LAGUERRE_POLY_TEST tests LAGUERRE_POLY.
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    23 May 2007
    //
    //  Author:
    //
    //    John Burkardt
    //
    {
        const int N_MAX = 12;

        double fx = 0;

        double[] fx2    = new double[N_MAX + 1];
        int      n      = 0;
        int      n_data = 0;
        double   x      = 0;

        Console.WriteLine("");
        Console.WriteLine("LAGUERRE_POLY_COEF:");
        Console.WriteLine("  LAGUERRE_POLY evaluates the Laguerre polynomial.");
        Console.WriteLine("");
        Console.WriteLine("     N      X        Exact F       L(N)(X)");
        Console.WriteLine("");

        n_data = 0;

        for (;;)
        {
            Burkardt.Values.Laguerre.laguerre_polynomial_values(ref n_data, ref n, ref x, ref fx);

            if (n_data == 0)
            {
                break;
            }

            Laguerre.laguerre_poly(n, x, ref fx2);

            Console.WriteLine("  "
                              + n.ToString(CultureInfo.InvariantCulture).PadLeft(8) + "  "
                              + x.ToString(CultureInfo.InvariantCulture).PadLeft(8) + "  "
                              + fx.ToString(CultureInfo.InvariantCulture).PadLeft(14) + "  "
                              + fx2[n].ToString(CultureInfo.InvariantCulture).PadLeft(14) + "");
        }
    }
    public static void laguerre_associated_values_test()
    //****************************************************************************80
    //
    //  Purpose:
    //
    //    LAGUERRE_ASSOCIATED_VALUES_TEST tests LAGUERRE_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("LAGUERRE_ASSOCIATED_VALUES_TEST:");
        Console.WriteLine("  LAGUERRE_ASSOCIATED_VALUES stores values of");
        Console.WriteLine("  the associated Laguerre polynomials.");
        Console.WriteLine("");
        Console.WriteLine("     N     M    X             L(N,M)(X)");
        Console.WriteLine("");
        int n_data = 0;

        for (;;)
        {
            Laguerre.laguerre_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 laguerre_general_values_test()
    //****************************************************************************80
    //
    //  Purpose:
    //
    //    LAGUERRE_GENERAL_VALUES_TEST tests LAGUERRE_GENERAL_VALUES.
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    26 January 2015
    //
    //  Author:
    //
    //    John Burkardt
    //
    {
        double a  = 0;
        double fx = 0;
        int    n  = 0;
        double x  = 0;

        Console.WriteLine("");
        Console.WriteLine("LAGUERRE_GENERAL_VALUES_TEST:");
        Console.WriteLine("  LAGUERRE_GENERAL_VALUES stores values of");
        Console.WriteLine("  the generalized Laguerre function.");
        Console.WriteLine("");
        Console.WriteLine("     N     A    X             L(N,A)(X)");
        Console.WriteLine("");
        int n_data = 0;

        for (;;)
        {
            Laguerre.laguerre_general_values(ref n_data, ref n, ref a, ref x, ref fx);
            if (n_data == 0)
            {
                break;
            }

            Console.WriteLine("  "
                              + n.ToString(CultureInfo.InvariantCulture).PadLeft(6) + "  "
                              + a.ToString(CultureInfo.InvariantCulture).PadLeft(12) + "  "
                              + x.ToString(CultureInfo.InvariantCulture).PadLeft(12) + "  "
                              + fx.ToString("0.################").PadLeft(24) + "");
        }
    }
    public static void laguerre_polynomial_test08(int p, int e)

    //****************************************************************************80
    //
    //  Purpose:
    //
    //    LAGUERRE_POLYNOMIAL_TEST08 tests L_POWER_PRODUCT.
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    11 March 2012
    //
    //  Author:
    //
    //    John Burkardt
    //
    //  Parameters:
    //
    //    Input, int P, the maximum degree of the polynomial
    //    factors.
    //
    //    Input, int E, the exponent of X.
    //
    {
        double[] table;

        Console.WriteLine("");
        Console.WriteLine("LAGUERRE_POLYNOMIAL_TEST08");
        Console.WriteLine("  Compute a power product table for L(n,x).");
        Console.WriteLine("");
        Console.WriteLine("  Tij = integral ( 0 <= x < +oo ) x^e L(i,x) L(j,x) exp(-x) dx");

        Console.WriteLine("");
        Console.WriteLine("  Maximum degree P = " + p + "");
        Console.WriteLine("  Exponent of X, E = " + e + "");

        table = Laguerre.l_power_product(p, e);

        typeMethods.r8mat_print(p + 1, p + 1, table, "  Power product table:");
    }
    public static void laguerre_polynomial_test03()

    //****************************************************************************80
    //
    //  Purpose:
    //
    //    LAGUERRE_POLYNOMIAL_TEST03 tests L_POLYNOMIAL_ZEROS.
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    11 March 2012
    //
    //  Author:
    //
    //    John Burkardt
    //
    {
        int degree;

        double[] hz;
        string   title;

        double[] z;

        Console.WriteLine("");
        Console.WriteLine("LAGUERRE_POLYNOMIAL_TEST03:");
        Console.WriteLine("  L_POLYNOMIAL_ZEROS computes the zeros of L(n,x)");
        Console.WriteLine("  Check by calling L_POLYNOMIAL there.");

        for (degree = 1; degree <= 5; degree++)
        {
            z     = Laguerre.l_polynomial_zeros(degree);
            title = "  Computed zeros for L(" + degree + ",z):";
            typeMethods.r8vec_print(degree, z, title);

            hz    = Laguerre.l_polynomial(degree, degree, z);
            title = "  Evaluate L(" + degree + ",z):";
            typeMethods.r8vec_print(degree, hz, title, aIndex: +degree * degree);
        }
    }
    public static void laguerre_polynomial_test07(int p, double b)

    //****************************************************************************80
    //
    //  Purpose:
    //
    //    LAGUERRE_POLYNOMIAL_TEST07 tests L_EXPONENTIAL_PRODUCT.
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    11 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.
    //
    {
        double[] table;

        Console.WriteLine("");
        Console.WriteLine("LAGUERREE_POLYNOMIAL_TEST07");
        Console.WriteLine("  Compute an exponential product table for L(n,x):");
        Console.WriteLine("");
        Console.WriteLine("  Tij = integral ( 0 <= x < +oo ) exp(b*x) Ln(i,x) Ln(j,x) exp(-x) dx");
        Console.WriteLine("");
        Console.WriteLine("  Maximum degree P = " + p + "");
        Console.WriteLine("  Exponential argument coefficient B = " + b + "");

        table = Laguerre.l_exponential_product(p, b);

        typeMethods.r8mat_print(p + 1, p + 1, table, "  Exponential product table:");
    }
Exemple #9
0
    public static void laguerre_associated_test()

    //****************************************************************************80
    //
    //  Purpose:
    //
    //    LAGUERRE_ASSOCIATED_TEST tests LAGUERRE_ASSOCIATED.
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    23 May 2007
    //
    //  Author:
    //
    //    John Burkardt
    //
    {
        const int N      = 6;
        const int N_TEST = 6;

        double[] c = new double[N + 1];
        int      i;

        int[] m_test =
        {
            0, 0, 1, 2, 3, 1
        }

        ;
        double[] x_test =
        {
            0.0, 1.0, 0.0, 0.5, 0.5, 0.5
        }

        ;

        Console.WriteLine("");
        Console.WriteLine("LAGUERRE_ASSOCIATED_TEST");
        Console.WriteLine("  LAGUERRE_ASSOCIATED evaluates the associated Laguerre");
        Console.WriteLine("  polynomials.");

        for (i = 0; i < N_TEST; i++)
        {
            int    m = m_test[i];
            double x = x_test[i];

            Console.WriteLine("");
            Console.WriteLine("  Table of L(N,M)(X) for");
            Console.WriteLine("");
            Console.WriteLine("  N(max) = " + N + "");
            Console.WriteLine("  M      = " + m + "");
            Console.WriteLine("  X =      " + x + "");
            Console.WriteLine("");

            Laguerre.laguerre_associated(N, m, x, ref c);

            int j;
            for (j = 0; j <= N; j++)
            {
                Console.WriteLine("  "
                                  + j.ToString(CultureInfo.InvariantCulture).PadLeft(6) + "  "
                                  + c[j].ToString(CultureInfo.InvariantCulture).PadLeft(14) + "");
            }
        }
    }
Exemple #10
0
    public static void laguerre_poly_coef_test()

    //****************************************************************************80
    //
    //  Purpose:
    //
    //    TEST055 tests LAGUERRE_POLY_COEF.
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    23 May 2007
    //
    //  Author:
    //
    //    John Burkardt
    //
    {
        const int N = 5;

        double[] c = new double[(N + 1) * (N + 1)];
        int      i;
        int      j;

        Console.WriteLine("");
        Console.WriteLine("LAGUERRE_POLY_COEF_TEST");
        Console.WriteLine("  LAGUERRE_POLY_COEF determines Laguerre ");
        Console.WriteLine("  polynomial coefficients.");

        Laguerre.laguerre_poly_coef(N, ref c);

        for (i = 0; i <= N; i++)
        {
            Console.WriteLine("");
            Console.WriteLine("  L(" + i + ")");
            Console.WriteLine("");
            for (j = i; 0 <= j; j--)
            {
                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;
                }
            }
        }

        for (i = 0; i <= N; i++)
        {
            double fact = typeMethods.r8_factorial(i);
            Console.WriteLine("");
            Console.WriteLine("  Factorially scaled L(" + i + ")");
            Console.WriteLine("");
            for (j = i; 0 <= j; j--)
            {
                switch (j)
                {
                case 0:
                    Console.WriteLine((fact * c[i + j * (N + 1)]).ToString(CultureInfo.InvariantCulture).PadLeft(14) + "");
                    break;

                case 1:
                    Console.WriteLine((fact * c[i + j * (N + 1)]).ToString(CultureInfo.InvariantCulture).PadLeft(14) + " * x");
                    break;

                default:
                    Console.WriteLine((fact * c[i + j * (N + 1)]).ToString(CultureInfo.InvariantCulture).PadLeft(14) + " * x^" + j + "");
                    break;
                }
            }
        }
    }
    public static void laguerre_polynomial_test01()

    //****************************************************************************80
    //
    //  Purpose:
    //
    //    LAGUERRE_POLYNOMIAL_TEST01 tests L_POLYNOMIAL.
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    11 March 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("LAGUERRE_POLYNOMIAL_TEST01:");
        Console.WriteLine("  L_POLYNOMIAL_VALUES stores values of");
        Console.WriteLine("  the Laguerre polynomials.");
        Console.WriteLine("  L_POLYNOMIAL evaluates the polynomial.");
        Console.WriteLine("");
        Console.WriteLine("                        Tabulated                 Computed");
        Console.WriteLine("     N        X           L(N,X)                    L(N,X)                     Error");
        Console.WriteLine("");

        n_data = 0;

        for (;;)
        {
            Laguerre.l_polynomial_values(ref n_data, ref n, ref x, ref fx1);

            if (n_data == 0)
            {
                break;
            }

            x_vec[0] = x;
            fx2_vec  = Laguerre.l_polynomial(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().PadLeft(8) + "");
        }
    }
    public static void laguerre_polynomial_test04()

    //****************************************************************************80
    //
    //  Purpose:
    //
    //    LAGUERRE_POLYNOMIAL_TEST04 tests L_QUADRATURE_RULE.
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    11 March 2012
    //
    //  Author:
    //
    //    John Burkardt
    //
    {
        int e;

        double[] f;
        int      i;
        int      n;
        double   q;
        double   q_exact;

        double[] w;
        double[] x;

        Console.WriteLine("");
        Console.WriteLine("LAGUERRE_POLYNOMIAL_TEST04:");
        Console.WriteLine("  L_QUADRATURE_RULE computes the quadrature rule");
        Console.WriteLine("  associated with L(n,x)");

        n = 7;
        x = new double[n];
        w = new double[n];

        QuadratureRule.l_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 ( 0 <= X < +00 ) X^E exp(-X) dx");
        Console.WriteLine("");
        Console.WriteLine("   E       Q_Estimate      Q_Exact");
        Console.WriteLine("");

        f = new double[n];

        for (e = 0; e <= 2 * n - 1; e++)
        {
            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;
            }
            }

            q       = typeMethods.r8vec_dot_product(n, w, f);
            q_exact = Laguerre.l_integral(e);
            Console.WriteLine("  " + e.ToString().PadLeft(2)
                              + "  " + q.ToString().PadLeft(14)
                              + "  " + q_exact.ToString().PadLeft(14) + "");
        }
    }
    public static void laguerre_polynomial_test02()

    //****************************************************************************80
    //
    //  Purpose:
    //
    //    LAGUERRE_POLYNOMIAL_TEST02 tests L_POLYNOMIAL_COEFFICIENTS.
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    11 March 2012
    //
    //  Author:
    //
    //    John Burkardt
    //
    {
        int N = 10;

        double[] c;
        int      i;
        int      j;

        Console.WriteLine("");
        Console.WriteLine("LAGUERRE_POLYNOMIAL_TEST02");
        Console.WriteLine("  L_POLYNOMIAL_COEFFICIENTS determines Laguerre polynomial coefficients.");

        c = Laguerre.l_polynomial_coefficients(N);

        for (i = 0; i <= N; i++)
        {
            Console.WriteLine("");
            Console.WriteLine("  L(" + i + ",x) =");
            Console.WriteLine("");
            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().PadLeft(14) + "");
                        ;
                        break;

                    case 1:
                        Console.WriteLine(c[i + j * (N + 1)].ToString().PadLeft(14) + " * x");
                        break;

                    default:
                        Console.WriteLine(c[i + j * (N + 1)].ToString().PadLeft(14) + " * x^" + j + "");
                        break;
                    }

                    break;
                }
            }
        }
    }