Python Glossary Русский

all Python 3cmathfunction

cmath.cosh()

hyperbolic functions

The hyperbolic cosine of a complex argument; for an imaginary argument cosh(i·x) = cos(x).

Syntax

cmath.cosh(z)

In the complex plane hyperbolic and trigonometric functions are the same function with a rotated argument: cosh(iπ) = cos(π) = -1. The practical side: math.cosh is faster for real numbers and returns a float, while cmath.cosh always returns complex, even for 0.

Examples

import cmath
print(cmath.cosh(1j * cmath.pi))  # → (-1+0j)
print(cmath.cosh(0))  # → (1+0j)

See also

Open in the full glossarydocs.python.orgReport an inaccuracy