Artemis.Engine.Maths.SpecialFunctions.Stirf C# (CSharp) Method

Stirf() private static method

Return the gamma function computed by Stirling's formula.
private static Stirf ( double x ) : double
x double
return double
        private static double Stirf(double x)
        {
            double MAXSTIR = 143.01608;

            double w = 1.0/x;
            double y = Math.Exp(x);

            w = 1.0 + w*polevl(w, STIR, 4);

            if (x > MAXSTIR)
            {
                /* Avoid overflow in Math.Pow() */
                double v = Math.Pow(x, 0.5 * x - 0.25);
                y = v*(v/y);
            }
            else
            {
                y = Math.Pow(x, x - 0.5) / y;
            }
            y = SQTPI*y*w;
            return y;
        }