This module provides access to mathematical functions for complex
numbers. The functions in this module accept integers, floating-point
numbers or complex numbers as arguments. They will also accept any
Python object that has either a
__complex__() or a
method: these methods are used to convert the object to a complex or
floating-point number, respectively, and the function is then applied
to the result of the conversion.
Return the phase of x (also known as the argument of x), as a float.
phase(x)is equivalent to
math.atan2(x.imag, x.real). The result lies in the range [-π, π], and the branch cut for this operation lies along the negative real axis, continuous from above. On systems with support for signed zeros (which includes most systems in current use), this means that the sign of the result is the same as the sign of
x.imag, even when
>>> phase(complex(-1.0, 0.0)) 3.141592 >>> phase(complex(-1.0, -0.0)) -3.14159
Return the representation of x in polar coordinates. Returns a pair
(r, phi)where r is the modulus of x and phi is the phase of x.
polar(x)is equivalent to
Return the complex number x with polar coordinates r and phi. Equivalent to
r * (math.cos(phi) + math.sin(phi)*1j).
Return the exponential value
Returns the natural logarithm of x. There is one branch cut, from 0 along the negative real axis to -∞, continuous from above.
Return the square root of x. This has the same branch cut as
Return the cosine of x.
Return the sine of x.
The mathematical constant e, as a float.
The mathematical constant π, as a float.