This module is always available.
It provides access to mathematical functions for complex numbers.
The functions are:
- acos (x)
-
Return the arc cosine of x.
- acosh (x)
-
Return the hyperbolic arc cosine of x.
- asin (x)
-
Return the arc sine of x.
- asinh (x)
-
Return the hyperbolic arc sine of x.
- atan (x)
-
Return the arc tangent of x.
- atanh (x)
-
Return the hyperbolic arc tangent of x.
- cos (x)
-
Return the cosine of x.
- cosh (x)
-
Return the hyperbolic cosine of x.
- exp (x)
-
Return the exponential value e**x.
- log (x)
-
Return the natural logarithm of x.
- log10 (x)
-
Return the base-10 logarithm of x.
- sin (x)
-
Return the sine of x.
- sinh (x)
-
Return the hyperbolic sine of x.
- sqrt (x)
-
Return the square root of x.
- tan (x)
-
Return the tangent of x.
- tanh (x)
-
Return the hyperbolic tangent of x.
The module also defines two mathematical constants:
- pi
-
The mathematical constant pi, as a real.
- e
-
The mathematical constant e, as a real.
Note that the selection of functions is similar, but not identical, to
that in module math. The reason for having
two modules is, that some users aren't interested in complex numbers,
and perhaps don't even know what they are. They would rather have
math.sqrt(-1) raise an exception than return a complex number.
Also note that the functions defined in cmath always return a
complex number, even if the answer can be expressed as a real number
(in which case the complex number has an imaginary part of zero).