Python Glossary Русский

all Python 3cmathfunction

cmath.acosh()

hyperbolic functions

The inverse hyperbolic cosine of a complex number. Unlike math.acosh, it is defined for arguments below 1 too.

Syntax

cmath.acosh(z)

math.acosh(0.5) raises ValueError, because the real acosh exists only for x ≥ 1, while cmath.acosh(0.5) returns 1.0471975511965979j, that is i·π/3. If such an input signals bad data in your task, cmath will hide it; pick the module on purpose.

Examples

import cmath
import math
print(cmath.acosh(0.5))  # → 1.0471975511965979j
try:
    math.acosh(0.5)
except ValueError as e:
    print(type(e).__name__)  # → ValueError

See also

Common errors

Open in the full glossarydocs.python.orgReport an inaccuracy