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

Y1() public static method

Returns the Bessel function of the second kind, of order 1 of the specified number.
public static Y1 ( double x ) : double
x double
return double
        public static double Y1(double x)
        {
            if (x < 8.0)
            {
                double y = x*x;
                double ans1 = x*(-0.4900604943e13 + y*(0.1275274390e13
                    + y*(-0.5153438139e11 + y*(0.7349264551e9
                    + y*(-0.4237922726e7 + y*0.8511937935e4)))));
                double ans2 = 0.2499580570e14 + y*(0.4244419664e12
                    + y*(0.3733650367e10 + y*(0.2245904002e8
                    + y*(0.1020426050e6 + y*(0.3549632885e3 + y)))));
                return (ans1 / ans2) + 0.636619772 * (J1(x) * Math.Log(x) - 1.0 / x);
            }
            else
            {
                double z = 8.0/x;
                double y = z*z;
                double xx = x - 2.356194491;
                double ans1 = 1.0 + y*(0.183105e-2 + y*(-0.3516396496e-4
                    + y*(0.2457520174e-5 + y*(-0.240337019e-6))));
                double ans2 = 0.04687499995 + y*(-0.2002690873e-3
                    + y*(0.8449199096e-5 + y*(-0.88228987e-6
                    + y*0.105787412e-6)));
                return Math.Sqrt(0.636619772 / x) *
                    (Math.Sin(xx) * ans1 + z * Math.Cos(xx) * ans2);
            }
        }