math.cosh()

Anonymous contributor's avatar
Anonymous contributor
Published Sep 27, 2024
Contribute to Docs

In Python, the math.cosh() method returns the hyperbolic cosine of a number which is equivalent to (math.exp(x) + math.exp(-x)) / 2.

Syntax

math.cosh(x)
  • x: A numeric value whose hyperbolic cosine is to be calculated.

Example 1

The following example uses math.cosh() to return the hyperbolic cosine of integer 1:

import math
print(math.cosh(1))

The above code gives the following output:

1.5430806348152437

Note: If the input is not a number, a TypeError is raised.

Example 2

The following example uses math.cosh() to return the hyperbolic cosine of the float 8.9:

import math
print(math.cosh(8.9))

The above code gives the following output:

3665.986837772461

Codebyte Example

Run the following example to understand the working of math.cosh() method:

Code
Output
Loading...

All contributors

Contribute to Docs

Learn Python on Codecademy