示例#1
0
        private static MultiPrecision <N> BesselKLimit(MultiPrecision <N> nu, MultiPrecision <N> z)
        {
            Consts.BesselLimitCoef table = Consts.Bessel.LimitCoef(nu);

            MultiPrecision <Plus4 <N> > z_ex = z.Convert <Plus4 <N> >();
            MultiPrecision <Plus4 <N> > v    = 1 / z_ex;

            MultiPrecision <Plus4 <N> > x = 0, p = 1;

            for (int k = 0; k <= Consts.BesselIK.LimitApproxTerms; k++, p *= v)
            {
                MultiPrecision <Plus4 <N> > c = p * table.Value(k);

                x += c;

                if (c.IsZero || x.Exponent - c.Exponent > MultiPrecision <Plus1 <N> > .Bits)
                {
                    break;
                }
            }

            MultiPrecision <Plus1 <N> > z_ex1 = z.Convert <Plus1 <N> >();
            MultiPrecision <Plus1 <N> > r     =
                MultiPrecision <Plus1 <N> > .Exp(-z_ex1) * MultiPrecision <Plus1 <N> > .Sqrt(MultiPrecision <Plus1 <N> > .PI / (2 * z_ex1));

            MultiPrecision <Plus1 <N> > y = r * x.Convert <Plus1 <N> >();

            return(y.Convert <N>());
        }
示例#2
0
        private static MultiPrecision <N> BesselYLimit(MultiPrecision <N> nu, MultiPrecision <N> z)
        {
            Consts.BesselLimitCoef table = Consts.Bessel.LimitCoef(nu);

            MultiPrecision <Plus4 <N> > z_ex = z.Convert <Plus4 <N> >();
            MultiPrecision <Plus4 <N> > v    = 1 / z_ex;
            MultiPrecision <Plus4 <N> > w    = v * v;

            MultiPrecision <Plus4 <N> > x = 0, y = 0, p = 1, q = v;

            Sign sign = Sign.Plus;

            for (int k = 0; k <= Consts.BesselJY.LimitApproxTerms; k++, p *= w, q *= w)
            {
                MultiPrecision <Plus4 <N> > c = p * table.Value(k * 2);
                MultiPrecision <Plus4 <N> > s = q * table.Value(k * 2 + 1);

                if (sign == Sign.Plus)
                {
                    x   += c;
                    y   += s;
                    sign = Sign.Minus;
                }
                else
                {
                    x   -= c;
                    y   -= s;
                    sign = Sign.Plus;
                }

                if (!c.IsZero && x.Exponent - c.Exponent <= MultiPrecision <Plus2 <N> > .Bits)
                {
                    continue;
                }
                if (!s.IsZero && y.Exponent - s.Exponent <= MultiPrecision <Plus2 <N> > .Bits)
                {
                    continue;
                }

                break;
            }

            MultiPrecision <Plus4 <N> > omega = z_ex - (2 * nu.Convert <Plus4 <N> >() + 1) * MultiPrecision <Plus4 <N> > .PI / 4;
            MultiPrecision <Plus4 <N> > m     = x * MultiPrecision <Plus4 <N> > .Sin(omega) + y * MultiPrecision <Plus4 <N> > .Cos(omega);

            MultiPrecision <Plus4 <N> > t = m * MultiPrecision <Plus4 <N> > .Sqrt(2 / (MultiPrecision <Plus4 <N> > .PI *z_ex));

            return(t.Convert <N>());
        }
示例#3
0
        private static MultiPrecision <N> BesselILimit(MultiPrecision <N> nu, MultiPrecision <N> z)
        {
            Consts.BesselLimitCoef table = Consts.Bessel.LimitCoef(nu);

            MultiPrecision <Plus4 <N> > z_ex = z.Convert <Plus4 <N> >();
            MultiPrecision <Plus4 <N> > v    = 1 / z_ex;

            MultiPrecision <Plus4 <N> > x = 0, p = 1;

            Sign sign = Sign.Plus;

            for (int k = 0; k <= Consts.BesselIK.LimitApproxTerms; k++, p *= v)
            {
                MultiPrecision <Plus4 <N> > c = p * table.Value(k);

                if (sign == Sign.Plus)
                {
                    x   += c;
                    sign = Sign.Minus;
                }
                else
                {
                    x   -= c;
                    sign = Sign.Plus;
                }

                if (c.IsZero || x.Exponent - c.Exponent > MultiPrecision <Plus1 <N> > .Bits)
                {
                    break;
                }
            }

            MultiPrecision <Plus1 <N> > z_ex1 = z.Convert <Plus1 <N> >();
            MultiPrecision <Plus1 <N> > r     =
                MultiPrecision <Plus1 <N> > .Exp(z_ex1) / MultiPrecision <Plus1 <N> > .Sqrt(2 *MultiPrecision <Plus1 <N> > .PI *z_ex1);

            MultiPrecision <Plus1 <N> > y = r * x.Convert <Plus1 <N> >();

            return(y.Convert <N>());
        }