Esempio n. 1
0
 def fdiff(self, argindex=4):
     if argindex == 1:
         # Diff wrt n
         raise ArgumentIndexError(self, argindex)
     elif argindex == 2:
         # Diff wrt m
         raise ArgumentIndexError(self, argindex)
     elif argindex == 3:
         # Diff wrt theta
         n, m, theta, phi = self.args
         return (m * C.cot(theta) * Ynm(n, m, theta, phi) +
                 sqrt((n - m)*(n + m + 1)) * C.exp(-I*phi) * Ynm(n, m + 1, theta, phi))
     elif argindex == 4:
         # Diff wrt phi
         n, m, theta, phi = self.args
         return I * m * Ynm(n, m, theta, phi)
     else:
         raise ArgumentIndexError(self, argindex)
Esempio n. 2
0
    def eval(cls, arg):
        arg = sympify(arg)

        if arg.is_Number:
            if arg is S.NaN:
                return S.NaN
            elif arg is S.Infinity:
                return S.One
            elif arg is S.NegativeInfinity:
                return S.NegativeOne
            elif arg is S.Zero:
                return S.Zero
            elif arg.is_negative:
                return -cls(-arg)
        else:
            i_coeff = arg.as_coefficient(S.ImaginaryUnit)

            if i_coeff is not None:
                return -S.ImaginaryUnit * C.cot(i_coeff)
            else:
                coeff, terms = arg.as_coeff_terms()

                if coeff.is_negative:
                    return -cls(-arg)
Esempio n. 3
0
    def eval(cls, arg):
        arg = sympify(arg)

        if arg.is_Number:
            if arg is S.NaN:
                return S.NaN
            elif arg is S.Infinity:
                return S.One
            elif arg is S.NegativeInfinity:
                return S.NegativeOne
            elif arg is S.Zero:
                return S.Zero
            elif arg.is_negative:
                return -cls(-arg)
        else:
            i_coeff = arg.as_coefficient(S.ImaginaryUnit)

            if i_coeff is not None:
                return -S.ImaginaryUnit * C.cot(i_coeff)
            else:
                coeff, terms = arg.as_coeff_terms()

                if coeff.is_negative:
                    return -cls(-arg)