Artemis.Engine.Maths.SpecialFunctions.Digamma C# (CSharp) Метод

Digamma() публичный статический Метод

Return the value of the digamma function (the logarithmic derivative of the gamma function) at x.
public static Digamma ( double x ) : double
x double
Результат double
        public static double Digamma(double x)
        {
            if (x < 0.0)
                return Digamma(1 - x) + Math.PI / Math.Tan(Math.PI * (1 - x));
            else if (x < 1.0)
                return Digamma(1 + x) - 1.0 / x;
            else if (x == 1.0)
                return GAMMA;
            else if (x == 2.0)
                return 1 - GAMMA;
            else if (x == 3.0)
                return 1.5 - GAMMA;
            else if (x > 3.0)
                return 0.5 * (Digamma(x / 2.0) + Digamma((x + 1) / 2.0)) + LN2;
            else
            {
                double TN_1 = 1.0;
                double TN = x - 2.0;
                double TN1;

                double result = KNC[0] + KNC[1] * TN;
                x -= 2;

                for (int i = 2; i < KNC.Length; i++)
                {
                    TN1 = 2.0 * x * TN - TN_1;
                    result += KNC[i] * TN1;
                    TN_1 = TN;
                    TN = TN1;
                }

                return result;
            }
        }