Exemplo n.º 1
0
    def as_real_imag(self, deep=True, **hints):
        """
        Returns this function as a complex coordinate.

        Examples
        ========

        >>> from sympy import I
        >>> from sympy.abc import x
        >>> from sympy.functions import log
        >>> log(x).as_real_imag()
        (log(Abs(x)), arg(x))
        >>> log(I).as_real_imag()
        (0, pi/2)
        >>> log(1+I).as_real_imag()
        (log(sqrt(2)), pi/4)
        >>> log(I*x).as_real_imag()
        (log(Abs(x)), arg(I*x))

        """
        if deep:
            abs = C.Abs(self.args[0].expand(deep, **hints))
            arg = C.arg(self.args[0].expand(deep, **hints))
        else:
            abs = C.Abs(self.args[0])
            arg = C.arg(self.args[0])
        if hints.get('log', False):  # Expand the log
            hints['complex'] = False
            return (log(abs).expand(deep, **hints), arg)
        else:
            return (log(abs), arg)
Exemplo n.º 2
0
 def as_real_imag(self, deep=True, **hints):
     if deep:
         abs = C.Abs(self.args[0].expand(deep, **hints))
         arg = C.arg(self.args[0].expand(deep, **hints))
     else:
         abs = C.Abs(self.args[0])
         arg = C.arg(self.args[0])
     if hints['log']:  # Expand the log
         hints['complex'] = False
         return (log(abs).expand(deep, **hints), arg)
     else:
         return (log(abs), arg)