Inheritance: ArgumentFunction
Example #1
0
        public static ScalarValue Psi(int n, ScalarValue z)
        {
            if (n < 0)
            {
                throw new YAMPArgumentRangeException("n", 0.0);
            }

            if (z.Re <= 0.0 && z.Im == 0)
            {
                return(ScalarValue.RealInfinity);
            }

            if (n == 0)
            {
                return(Psi0(z));
            }
            else if (n == 1)
            {
                return(Psi1(z));
            }

            var hzeta  = HzetaFunction.HurwitzZeta(n + 1.0, z);
            var ln_nf  = Helpers.Factorial(n);
            var result = hzeta * ln_nf;

            if (n % 2 == 0)
            {
                result = -result;
            }

            Helpers.Factorial(1);
            return(result);
        }
Example #2
0
        public static double Psi(int n, double x)
        {
            if (n < 0)
            {
                throw new YAMPArgumentRangeException("n", 0.0);
            }

            if (x <= 0.0)
            {
                throw new YAMPArgumentRangeException("x", 0.0);
            }

            if (n == 0)
            {
                return(Gamma.Psi(x));
            }
            else if (n == 1)
            {
                return(Psi1(x));
            }

            var hzeta  = HzetaFunction.HurwitzZeta(n + 1.0, x);
            var ln_nf  = Helpers.Factorial(n);
            var result = hzeta * ln_nf;

            if (n % 2 == 0)
            {
                result = -result;
            }

            Helpers.Factorial(1);

            return(result);
        }
Example #3
0
        static ScalarValue PsiXgt0(int n, ScalarValue z)
        {
            if (n == 0)
            {
                return(Psi0(z));
            }

            /* Abramowitz + Stegun 6.4.10 */
            var hzeta  = HzetaFunction.HurwitzZeta(n + 1.0, z);
            var ln_nf  = Helpers.Factorial(n);
            var result = hzeta * ln_nf;

            if (n % 2 == 0)
            {
                result = -result;
            }

            return(result);
        }
Example #4
0
        static double PsiXgt0(int n, double x)
        {
            if (n == 0)
            {
                return(Gamma.Psi(x));
            }

            /* Abramowitz + Stegun 6.4.10 */
            var hzeta  = HzetaFunction.HurwitzZeta(n + 1.0, x);
            var ln_nf  = Helpers.Factorial(n);
            var result = hzeta * ln_nf;

            if (n % 2 == 0)
            {
                result = -result;
            }

            return(result);
        }