Python Glossary Русский

all Python 3cmathfunction

cmath.atan()

trigonometry

The arctangent of a complex number. It is undefined at ±1j and raises ValueError there.

Syntax

cmath.atan(z)

For a real argument it matches math.atan, but as a complex value; there is no two-coordinate angle like math.atan2 here, cmath.phase does that job. The singular points ±1j give ValueError, although the function is well defined near them: atan(0.5j) = 0.5493061443340549j.

Examples

import cmath
print(cmath.atan(0.5j))  # → 0.5493061443340549j
try:
    cmath.atan(1j)
except ValueError as e:
    print(type(e).__name__)  # → ValueError

See also

Common errors

Open in the full glossarydocs.python.orgReport an inaccuracy