cmath – mathematical functions for complex numbers
This module implements a subset of the corresponding CPython module, as described below. For more information, refer to the original CPython documentation: cmath.
The cmath
module provides some basic mathematical functions for working with complex numbers.
Availability: not available on WiPy and ESP8266. Floating point support required for this module.
1. Functions
1.1. cos
cmath.cos(z)
Return the cosine of z
.
1.2. exp
cmath.exp(z)
Return the exponential of z
.
1.3. log
cmath.log(z)
Return the natural logarithm of z
. The branch cut is along the negative real axis.
1.4. log10
cmath.log10(z)
Return the base-10 logarithm of z
. The branch cut is along the negative real axis.
1.5. phase
cmath.phase(z)
Returns the phase of the number z
, in the range (-pi, +pi].
1.6. polar
cmath.polar(z)
Returns, as a tuple, the polar form of z
.
1.7. rect
cmath.rect(r, phi)
Returns the complex number with modulus r
and phase phi
.
1.8. sin
cmath.sin(z)
Return the sine of z
.
1.9. sqrt
cmath.sqrt(z)
Return the square-root of z
.
2. Constants
2.1. cmath.e
base of the natural logarithm
2.2. cmath.pi
the ratio of a circle’s circumference to its diameter