예제 #1
0
    def eval(cls, nu, z):
        if z.is_zero:
            if nu.is_zero:
                return S.One
            elif (nu.is_integer and nu.is_zero is False) or re(nu).is_positive:
                return S.Zero
            elif re(nu).is_negative and not (nu.is_integer is True):
                return S.ComplexInfinity
            elif nu.is_imaginary:
                return S.NaN
        if im(z) is S.Infinity or im(z) is S.NegativeInfinity:
            return S.Zero

        if z.could_extract_minus_sign():
            return (z)**nu * (-z)**(-nu) * besseli(nu, -z)
        if nu.is_integer:
            if nu.could_extract_minus_sign():
                return besseli(-nu, z)
            newz = z.extract_multiplicatively(I)
            if newz:  # NOTE we don't want to change the function if z==0
                return I**(-nu) * besselj(nu, -newz)

        # branch handling:
        from diofant import unpolarify, exp
        if nu.is_integer:
            newz = unpolarify(z)
            if newz != z:
                return besseli(nu, newz)
        else:
            newz, n = z.extract_branch_factor()
            if n != 0:
                return exp(2 * n * pi * nu * I) * besseli(nu, newz)
        nnu = unpolarify(nu)
        if nu != nnu:
            return besseli(nnu, z)
예제 #2
0
    def eval(cls, nu, z):
        if z.is_zero:
            if nu.is_zero:
                return S.Infinity
            elif re(nu).is_zero is False:
                return S.ComplexInfinity
            elif re(nu).is_zero:
                return S.NaN
        if im(z) is S.Infinity or im(z) is S.NegativeInfinity:
            return S.Zero

        if nu.is_integer:
            if nu.could_extract_minus_sign():
                return besselk(-nu, z)
예제 #3
0
 def _eval_rewrite_as_besseli(self, z):
     ot = Rational(1, 3)
     tt = Rational(2, 3)
     a = Pow(z, Rational(3, 2))
     if re(z).is_positive:
         return ot * sqrt(z) * (besseli(-ot, tt * a) - besseli(ot, tt * a))
     else:
         return ot * (Pow(a, ot) * besseli(-ot, tt * a) -
                      z * Pow(a, -ot) * besseli(ot, tt * a))
예제 #4
0
 def _eval_rewrite_as_besseli(self, z):
     ot = Rational(1, 3)
     tt = Rational(2, 3)
     a = tt * Pow(z, Rational(3, 2))
     if re(z).is_positive:
         return z / sqrt(3) * (besseli(-tt, a) + besseli(tt, a))
     else:
         a = Pow(z, Rational(3, 2))
         b = Pow(a, tt)
         c = Pow(a, -tt)
         return sqrt(ot) * (b * besseli(-tt, tt * a) +
                            z**2 * c * besseli(tt, tt * a))
예제 #5
0
 def _eval_rewrite_as_besseli(self, z):
     ot = Rational(1, 3)
     tt = Rational(2, 3)
     a = tt * Pow(z, Rational(3, 2))
     if re(z).is_positive:
         return z / 3 * (besseli(tt, a) - besseli(-tt, a))
     else:
         a = Pow(z, Rational(3, 2))
         b = Pow(a, tt)
         c = Pow(a, -tt)
         return ot * (z**2 * c * besseli(tt, tt * a) -
                      b * besseli(-ot, tt * a))
예제 #6
0
 def _eval_rewrite_as_besseli(self, z):
     ot = Rational(1, 3)
     tt = Rational(2, 3)
     a = Pow(z, Rational(3, 2))
     if re(z).is_positive:
         return sqrt(z) / sqrt(3) * (besseli(-ot, tt * a) +
                                     besseli(ot, tt * a))
     else:
         b = Pow(a, ot)
         c = Pow(a, -ot)
         return sqrt(ot) * (b * besseli(-ot, tt * a) +
                            z * c * besseli(ot, tt * a))
예제 #7
0
    def eval(cls, n, a, x):
        # For negative n the polynomials vanish
        # See http://functions.wolfram.com/Polynomials/GegenbauerC3/03/01/03/0012/
        if n.is_negative:
            return S.Zero

        # Some special values for fixed a
        if a == S.Half:
            return legendre(n, x)
        elif a == S.One:
            return chebyshevu(n, x)
        elif a == S.NegativeOne:
            return S.Zero

        if not n.is_Number:
            # Handle this before the general sign extraction rule
            if x == S.NegativeOne:
                if (re(a) > S.Half) is S.true:
                    return S.ComplexInfinity
                else:
                    # No sec function available yet
                    # return (cos(S.Pi*(a+n)) * sec(S.Pi*a) * gamma(2*a+n) /
                    #            (gamma(2*a) * gamma(n+1)))
                    return

            # Symbolic result C^a_n(x)
            # C^a_n(-x)  --->  (-1)**n * C^a_n(x)
            if x.could_extract_minus_sign():
                return S.NegativeOne**n * gegenbauer(n, a, -x)
            # We can evaluate for some special values of x
            if x == S.Zero:
                return (2**n * sqrt(S.Pi) * gamma(a + S.Half*n) /
                        (gamma((1 - n)/2) * gamma(n + 1) * gamma(a)) )
            if x == S.One:
                return gamma(2*a + n) / (gamma(2*a) * gamma(n + 1))
            elif x == S.Infinity:
                if n.is_positive:
                    return RisingFactorial(a, n) * S.Infinity
        else:
            # n is a given fixed integer, evaluate into polynomial
            return gegenbauer_poly(n, a, x)
예제 #8
0
 def _eval_rewrite_as_besselj(self, z):
     ot = Rational(1, 3)
     tt = Rational(2, 3)
     a = Pow(-z, Rational(3, 2))
     if re(z).is_negative:
         return ot * sqrt(-z) * (besselj(-ot, tt * a) + besselj(ot, tt * a))
예제 #9
0
 def _eval_rewrite_as_besselj(self, z):
     tt = Rational(2, 3)
     a = tt * Pow(-z, Rational(3, 2))
     if re(z).is_negative:
         return -z / sqrt(3) * (besselj(-tt, a) + besselj(tt, a))
예제 #10
0
 def _eval_rewrite_as_besselj(self, z):
     tt = Rational(2, 3)
     a = Pow(-z, Rational(3, 2))
     if re(z).is_negative:
         return z / 3 * (besselj(-tt, tt * a) - besselj(tt, tt * a))