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)
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))