예제 #1
0
    def eval(cls, y, x):
        sign_y = C.sign(y)

        if y.is_zero:
            if x.is_positive:
                return S.Zero
            elif x.is_zero:
                return S.NaN
            elif x.is_negative:
                return S.Pi
        elif x.is_zero:
            if sign_y.is_Number:
                return sign_y * S.Pi / 2
        else:
            abs_yx = C.Abs(y / x)
            if sign_y.is_Number and abs_yx.is_number:
                phi = C.atan(abs_yx)
                if x.is_positive:
                    return sign_y * phi
                else:
                    return sign_y * (S.Pi - phi)
예제 #2
0
파일: mul.py 프로젝트: vchekan/sympy
 def as_real_imag(self, deep=True, **hints):
     other = []
     coeff = S(1)
     for a in self.args:
         if a.is_real:
             coeff *= a
         elif a.is_commutative:
             # search for complex conjugate pairs:
             for i, x in enumerate(other):
                 if x == a.conjugate():
                     coeff *= C.Abs(x)**2
                     del other[i]
                     break
             else:
                 other.append(a)
         else:
             other.append(a)
     m = Mul(*other)
     if hints.get('ignore') == m:
         return None
     else:
         return (coeff * C.re(m), coeff * C.im(m))