Python CMath
cmath is a module that support math with complex numbers.
Contents
Functions
Function |
Meaning |
Example |
acos |
arc cosine |
acos(a) |
acosh |
hyperbolic arc cosine |
acosh(a) |
asin |
arc sine |
asin(a) |
asinh |
hyperbolic arch sine |
asinh(a) |
atan |
arc tangent |
atan(a) |
atanh |
hyperbolic arc tangent |
atanh(a) |
cos |
cosine |
cos(a) |
cosh |
hyperbolic cosine |
cosh(a) |
exp |
e to the power of a complex number |
exp(a) |
isclose |
tests if two complex numbers are close |
isclose(a, b) |
isfinite |
tests if all parts of a complex number are finite |
isfinite(a) |
isinf |
tests if any part of a complex number is infinite |
isinf(a) |
isnan |
tests if any part of a complex number is NaN |
isnan(a) |
log |
logarithm (natural logarithm if base unspecified) |
log(a, base) |
log10 |
base-10 logarithm |
log10(a) |
phase |
phase of a complex number |
phase(a) |
polar |
translate a complex number into polar coordinates (r, phi, ) |
polar(a) |
rect |
translate polar coordinates r and phi into a complex number |
rect(r, phi) |
sin |
sine |
sin(a) |
sinh |
hyperbolic sine |
sinh(a) |
sqrt |
square root |
sqrt(a) |
tan |
tangent |
tan(a) |
tanh |
hyperbolic tangent |
tanh(a) |
Constants
Name |
Value |
cmath.pi |
π as a float |
cmath.e |
e as a float |
cmath.tau |
τ as a float |
cmath.inf |
floating-point positive infinity; same as float('inf') |
cmath.infj |
complex(0.0, float('inf')) |
cmath.nan |
floating-point not a number; same as float('nan') |
cmath.nanj |
complex(0.0, float('nan')) |
See also
Python cmath module documentation