Python Glossary Русский

all Python 3cmathfunction

cmath.atanh()

hyperbolic functions

The inverse hyperbolic tangent of a complex number; it accepts values outside (-1, 1) too, but raises ValueError at ±1.

Syntax

cmath.atanh(z)

math.atanh(2) raises ValueError, while cmath.atanh(2) = (0.5493061443340549+1.5707963267948966j). The points ±1 remain singular in cmath too: atanh(1) raises ValueError instead of returning infinity. Code that switches to cmath to escape domain errors still fails at the edges.

Examples

import cmath
print(cmath.atanh(2))  # → (0.5493061443340549+1.5707963267948966j)
try:
    cmath.atanh(1)
except ValueError as e:
    print(type(e).__name__)  # → ValueError

See also

Common errors

Open in the full glossarydocs.python.orgReport an inaccuracy