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

J0() public static method

Returns the Bessel function of order 0 of the specified number.
public static J0 ( double x ) : double
x double
return double
        public static double J0(double x)
        {
            double ax;

            if ((ax = Math.Abs(x)) < 8.0)
            {
                double y = x*x;
                double ans1 = 57568490574.0 + y*(-13362590354.0 + y*(651619640.7
                    + y*(-11214424.18 + y*(77392.33017 + y*(-184.9052456)))));
                double ans2 = 57568490411.0 + y*(1029532985.0 + y*(9494680.718
                    + y*(59272.64853 + y*(267.8532712 + y*1.0))));

                return ans1/ans2;

            }
            else
            {
                double z = 8.0/ax;
                double y = z*z;
                double xx = ax - 0.785398164;
                double ans1 = 1.0 + y*(-0.1098628627e-2 + y*(0.2734510407e-4
                    + y*(-0.2073370639e-5 + y*0.2093887211e-6)));
                double ans2 = -0.1562499995e-1 + y*(0.1430488765e-3
                    + y*(-0.6911147651e-5 + y*(0.7621095161e-6
                    - y*0.934935152e-7)));

                return Math.Sqrt(0.636619772 / ax) *
                    (Math.Cos(xx) * ans1 - z * Math.Sin(xx) * ans2);
            }
        }