예제 #1
0
        /// <summary> Returns the exponentially scaled modified Bessel function
        /// of the second kind of order 1 of the argument.
        /// <p/>
        /// <tt>k1e(x) = exp(x) * k1(x)</tt>.
        /// </summary>
        /// <param name="x">The value to compute the Bessel function of.
        /// </param>
        public static double BesselK1e(double x)
        {
            if (x <= 0.0)
            {
                throw new ArithmeticException();
            }

            if (x <= 2.0)
            {
                double y = x * x - 2.0;
                return(Math.Log(0.5 * x) * BesselI1(x) + Evaluate.ChebyshevA(BesselK1A, y) / x * Math.Exp(x));
            }

            double x1 = 8.0 / x - 2.0;

            return(Evaluate.ChebyshevA(BesselK1B, x1) / Math.Sqrt(x));
        }
예제 #2
0
        /// <summary> Returns the modified Bessel function of the second kind
        /// of order 0 of the argument.
        /// <p/>
        /// The range is partitioned into the two intervals [0, 8] and
        /// (8, infinity). Chebyshev polynomial expansions are employed
        /// in each interval.
        /// </summary>
        /// <param name="x">The value to compute the Bessel function of.
        /// </param>
        public static double BesselK0(double x)
        {
            if (x <= 0.0)
            {
                throw new ArithmeticException();
            }

            if (x <= 2.0)
            {
                double y = x * x - 2.0;
                return(Evaluate.ChebyshevA(BesselK0A, y) - Math.Log(0.5 * x) * BesselI0(x));
            }

            double z = 8.0 / x - 2.0;

            return(Math.Exp(-x) * Evaluate.ChebyshevA(BesselK0B, z) / Math.Sqrt(x));
        }
예제 #3
0
        /// <summary>Returns the modified Bessel function of first kind, order 0 of the argument.
        /// <p/>
        /// The function is defined as <tt>i0(x) = j0( ix )</tt>.
        /// <p/>
        /// The range is partitioned into the two intervals [0, 8] and
        /// (8, infinity). Chebyshev polynomial expansions are employed
        /// in each interval.
        /// </summary>
        /// <param name="x">The value to compute the Bessel function of.
        /// </param>
        public static double BesselI0(double x)
        {
            if (x < 0)
            {
                x = -x;
            }

            if (x <= 8.0)
            {
                double y = (x / 2.0) - 2.0;
                return(Math.Exp(x) * Evaluate.ChebyshevA(BesselI0A, y));
            }

            double x1 = 32.0 / x - 2.0;

            return(Math.Exp(x) * Evaluate.ChebyshevA(BesselI0B, x1) / Math.Sqrt(x));
        }
예제 #4
0
        /// <summary>Returns the modified Bessel function of first kind,
        /// order 1 of the argument.
        /// <p/>
        /// The function is defined as <tt>i1(x) = -i j1( ix )</tt>.
        /// <p/>
        /// The range is partitioned into the two intervals [0, 8] and
        /// (8, infinity). Chebyshev polynomial expansions are employed
        /// in each interval.
        /// </summary>
        /// <param name="x">The value to compute the Bessel function of.
        /// </param>
        public static double BesselI1(double x)
        {
            double z = Math.Abs(x);

            if (z <= 8.0)
            {
                double y = (z / 2.0) - 2.0;
                z = Evaluate.ChebyshevA(BesselI1A, y) * z * Math.Exp(z);
            }
            else
            {
                double x1 = 32.0 / z - 2.0;
                z = Math.Exp(z) * Evaluate.ChebyshevA(BesselI1B, x1) / Math.Sqrt(z);
            }

            if (x < 0.0)
            {
                z = -z;
            }

            return(z);
        }