Working with complex numbers
Because complex numbers, that is, numbers that have an imaginary element, cannot be used with the regular math module functions, the cmath
module is available for these special numbers.
As a built-in module, it is always available for import. Of note, the functions accept integers, floats, and complex numbers as arguments. They will also accept any Python object that has a __complex__()
or __float__()
method as part of its class.
On systems that support signed zeros, branch cuts (https://en.wikipedia.org/wiki/Branch_point#Branch_cuts) are continuous on both sides of the cut, as the sign of the zero designates which side of the cut the branch is on. On systems that do not support signed zeros, continuity is noted for the specific functions in the next section.
How to do it...
The following functions and constants operate like their normal math cousins, except where noted:
exp(x)
: Calculate math constante
to the power ofx
.log(x[, base])
: There is one branch cut—from...